1

This issue has been a plague on my migration of an application from NativeScript 5.4.0 to NativeScript 6.3.3. I am now using webpack.config.js in combination with nativescript-worker-loader (Workers).

I have performed the required steps in the webpack file and the code that breaks on tns build android works when ran on a device with tns run android.

Error on tns build android:

         + adding aar plugin dependency: C:\Dev\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar
Warning: there already is an extend called com.tns.FragmentClass.
Warning: The static binding generator will generate extend from:vendor.js implementation
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:C:\Dev\platforms\android\app\src\main\java\com\tns\FragmentClass.java Class: com.tns.FragmentClass
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:112)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:50)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:runSbg'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_211\bin\java.exe'' finished with non-zero exit value 1

package.json:

{
  "description": "xx",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "xx.xx.xx.xx",
    "tns-ios": {
      "version": "6.0.1"
    },
    "tns-android": {
      "version": "6.0.0"
    }
  },
  "dependencies": {
    "@nstudio/nativescript-checkbox": "^1.0.0",
    "@nstudio/nativescript-floatingactionbutton": "^2.0.0",
    "base-64": "^0.1.0",
    "chokidar": "^3.3.1",
    "currency-formatter": "^1.3.2",
    "is-json": "^2.0.1",
    "lodash": "^4.17.15",
    "md5": "^2.2.1",
    "moment": "^2.24.0",
    "nativescript-activity-detection": "^0.1.1",
    "nativescript-android-utils": "^1.0.2",
    "nativescript-bitmap-factory": "^1.7.1",
    "nativescript-camera": "4.5.0",
    "nativescript-couchbase": "^1.0.18",
    "nativescript-dialog": "^0.1.0",
    "nativescript-drawingpad": "^3.0.3",
    "nativescript-drop-down": "^4.0.1",
    "nativescript-exit": "^1.0.1",
    "nativescript-geolocation": "^5.1.0",
    "nativescript-google-maps-sdk": "^2.7.0",
    "nativescript-gradient": "^2.0.1",
    "nativescript-imagepicker": "6.2.0",
    "nativescript-insomnia": "^1.2.2",
    "nativescript-localstorage": "^2.0.0",
    "nativescript-maskedinput": "0.0.3",
    "nativescript-permissions": "^1.3.6",
    "nativescript-phone": "^1.3.1",
    "nativescript-sqlite": "^2.3.3",
    "nativescript-sqlite-commercial": "file:custom_plugins/nativescript-sqlite-commercial-1.3.2-plugin.tgz",
    "nativescript-sqlite-encrypted": "file:custom_plugins/nativescript-sqlite-encrypted-1.4.0-plugin.tgz",
    "nativescript-statusbar": "^3.0.1",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-toast": "^1.4.6",
    "nativescript-ui-autocomplete": "^6.0.0",
    "nativescript-ui-calendar": "^6.0.0",
    "nativescript-ui-chart": "^7.1.1",
    "nativescript-ui-dataform": "^6.0.0",
    "nativescript-ui-gauge": "^6.0.0",
    "nativescript-ui-listview": "7.0.0",
    "nativescript-ui-sidedrawer": "^8.0.0",
    "nativescript-unit-test-runner": "0.7.0",
    "node-stopwatch": "0.0.1",
    "semver": "^5.4.1",
    "stopwatch": "^0.2.0",
    "stopwatch.js": "^1.1.1",
    "timer-stopwatch": "^0.2.0",
    "tns-core-modules": "6.3.0",
    "utf8": "^2.1.2"
  },
  "devDependencies": {
    "add": "^2.0.6",
    "babel-traverse": "6.25.0",
    "babel-types": "6.25.0",
    "babylon": "6.17.4",
    "chai": "^4.1.0",
    "karma": "4.1.0",
    "karma-chai": "^0.1.0",
    "karma-mocha": "^1.3.0",
    "karma-nativescript-launcher": "^0.4.0",
    "karma-webpack": "3.0.5",
    "lazy": "1.0.11",
    "mocha": "^7.0.1",
    "nativescript-dev-webpack": "1.0.1",
    "nativescript-worker-loader": "^0.10.0",
    "serialize-javascript": "^2.1.2",
    "tns-platform-declarations": "6.0.1",
    "typescript": "3.4.5"
  }
}

I have deleted and refreshed the node_modules, platforms, hooks many times and the only way I can build is to remove all references to my workers so that they are not included in the bundle.

I have also gone to forums with similar problems Case 1 and Case 2 and more to no avail.

Please let me know if anything else should be included in the question text. Thanks in advance.

wareisjared
  • 330
  • 1
  • 2
  • 17
  • My package.json is valid and can work with other projects according to the developer of the custom plugins (Nathanael Anderson). As well as it working almost the same in the pre-migration version. – wareisjared Feb 12 '20 at 09:18

2 Answers2

0

Try deleting your Gradle folder c:\users\**username**\.gradle In our experience we have seen this issue and clearing the Gradle folder with it's caches has solved it sometimes.

  • Hi Peter, that's quite useful and I'll try it in the future when coming to an odd standstill but unfortunately in this scenario it didn't work. – wareisjared Feb 13 '20 at 06:04
  • Hi Jared, we do have this issue currently on one particular NS project. The Android build works on one Windows machine perfectly, but from the same codebase on a Mac running Windows it fails. We have reinstalled Windows, compared all component versions (Gradle, Javam, Node, NPM, NS, Android), cleared Gradle, deleted node_modules, platforms, hooks tried everything for days now but to no avail-it always errors on FragmentClass.java Class when we try to build (emulator or production). We understand your frustration!!! If you find the solution please post it :) Even a new PC didn't work! Arghh! – Peter Chapman Feb 13 '20 at 10:31
  • It definitely has something to do with using webpacker with workers and nativescript-worker-loader. I have replicated the issue in smaller demo projects and can fix the build issue at the cost of losing functionality in my workers. Hopefully we can find a solution soon. – wareisjared Feb 14 '20 at 05:58
0

This Answer serves as a temporary one and I will change it once it is official.

This bug has been reported as "a bug in the NativeScript build system" in the latest version of NativeScript.

This should no longer be an error that occurs in newer versions of NativeScript and will be patched soon in a new version.

wareisjared
  • 330
  • 1
  • 2
  • 17