Nativescript: Tns run android leads to Exception in thread "main" java.io.IOException: File already exists

Created on 18 Jun 2018  路  8Comments  路  Source: NativeScript/NativeScript

I'm not able to run my project after ugrading from NS from 3.4.0 to 4.1.0 :

Warning: there already is an extend called com.tns.NativeScriptActivity.
Warning: there already is an extend called com.tns.FragmentClass.
Exception in thread "main" java.io.IOException: File already exists. This may lead to undesired behavior.
Please change the name of one of the extended classes.
File:/home/adminuser/fastmail/pardeltrack/Parcelcheck/platforms/android/app/src/main/java/com/tns/gen/java/lang/Object_picker_16_32_TimeChangedListenerImpl.java Class:
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:78)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:48)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:runSbg'.
> Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
After upgrading nativescript to 4.1.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6m 34s
Unable to apply changes on device: 192.168.1.7:5555. Error is: Command ./gradlew failed with exit code 1.
Executing after-watch hook from /home/adminuser/fastmail/pardeltrack/Parcelcheck/hooks/after-watch/nativescript-dev-sass.js
Stopping sass watch
Executing after-watch hook from /home/adminuser/fastmail/pardeltrack/Parcelcheck/hooks/after-watch/nativescript-dev-sass.js

here my packages.json :

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.ns.ParcelCheck",
    "tns-android": {
      "version": "4.1.3"
    }
  },
  "scripts": {
    "lint": "eslint \"app/**/*.js\""
  },
  "dependencies": {
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-dataform": "^3.6.1",
    "nativescript-ui-listview": "^3.5.8",
    "nativescript-ui-sidedrawer": "^4.1.1",

    "tns-core-modules": "^4.1.0"
  }

}

needs more info android

All 8 comments

Hey @essadek,
Few more questions:

  1. Are you using the nativescript-dev-webpack plugin to bundle you app.
  2. Do you have workers in your code?

You might want to check out https://github.com/NativeScript/android-runtime/issues/778. It looks like a similar problem especially if the answer of 1. is 2. is "yes".

hi @vakrilov

Are you using the nativescript-dev-webpack plugin to bundle you app.

check my package.json

Do you have workers in your code?

No I don't use workers at least for now

@essadek please try resetting your project by removingnode_modules, platforms and hooks folders and then rebuild the project. If that does not solve the issue can you please share the entire content of dependencies and devDependencies of your project.

Thanks @NickIliev for the help. I had to to create new project and now the app is running without any issue.

I was getting the same error and issue was that I was using this bit of code android.webkit.WebViewClient.extend({...}): and more than one places. So seems like this error comes up when extending a class with same name or in the above fashion with .extend({}).

I didn't know how do I rename class in the case of .extend({}) (if anyone knows please share) so I removed this from other place to fix the issue.

I am facing same similar issue kindly help me ( I have deleted hooks + node_modules + android platform ) and installed again but things not working.

I am facing same similar issue kindly help me ( I have deleted hooks + node_modules + android platform ) and installed again but things not working.

done by "tns build android --bundle" now its working

If you deployed the application before, maybe you can uninstall it and run again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

valentinstoychev picture valentinstoychev  路  3Comments

yclau picture yclau  路  3Comments

tsonevn picture tsonevn  路  3Comments

pocesar picture pocesar  路  3Comments

kn9ts picture kn9ts  路  3Comments