NathanaelA / nativescript-sqlite

SQLite Bindng for NativeScript
MIT License
160 stars 53 forks source link

Build fails with NativeScript 6.5 ./gradlew (failed with exit code 1) #161

Closed SpurguX closed 4 years ago

SpurguX commented 4 years ago

The build process of my NS-Vue project started failing after I updated NativeScript (from 6.2 to 6.5) and it seems to have something to do with this library. I've also written a Stack Overflow post about the problem. However, I could now verify that the error occurs only when nativescript-sqlite is installed in the project. When I remove the library, the error disappears.

I've been having difficulties debugging the problem. At first I thought it was a webpack problem (as I was only running tns run android and getting exit code 0 from webpack) but after running the build command with the debug flag I noticed that gradlew build fails. This is the stack trace, which is not very informative:

Error: Command ./gradlew failed with exit code 1
    at Errors.failWithOptions (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:149:28)
    at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:120:21)
    at GradleCommandService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:42:30)
    at Generator.throw (<anonymous>)
    at rejected (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:5:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I figured it might have something to do with the library trying to import non-existent optional plugins so I tried removing the function definitions of and calls to TryLoadingEncryptionPlugin and TryLoadingSyncPlugin (as the project is only using the Commercial one), but to no avail. I have also tried adding the non-used plugins to webpack externals as per the docs but that never seemed to have any effect (the warnings remain despite pushing to externals even when the project is using NativeScript 6.2.1, in which case the build doesn't fail).

So far I haven't been able to get any more specific info as to what actually causes the error, only that it doesn't occur if nativescript-sqlite isn't installed. Any ideas what it could be about or how to debug?

Here are the parts I thought are relevant from my current package.json:

  "nativescript": {
    ...
    "tns-ios": {
      "version": "6.5.0"
    },
    "tns-android": {
      "version": "6.5.0"
    }
  },
  "dependencies": {
    ...
    "@nativescript/core": "^6.5.1",
    "@vue/devtools": "^5.3.3",
    "nativescript": "^6.5.0",
    "nativescript-sqlite": "file:nativescript-sqlite",
    "nativescript-sqlite-commercial": "file:commercial-sqlite-2.4.0/nativescript-sqlite-commercial-1.3.2.tgz",
    "nativescript-vue": "^2.6.1",
    "nativescript-vue-devtools": "^1.4.0",
    "tns-core-modules-widgets": "^6.5.0",
    ...
  }
  "devDependencies": {
    ...
    "nativescript-dev-webpack": "~1.5.1",
    "nativescript-vue-template-compiler": "^2.6.0",
    "vue-loader": "^15.9.1"
    ...
  },

The package nativescript-sqlite is also version 2.4.0.

NathanaelA commented 4 years ago

Actually this is a bug in the NS-Webpack loader 0.11. You need to downgrade it to v0.10 and it will work. I already have a PR to fix the loader; but it hasn't been pushed out yet...

SpurguX commented 4 years ago

Great, thanks, this solved my problem! :slightly_smiling_face:

In case anyone else reads this and has the same problem, the actual name of the package that needs to be downgraded to v0.10 is nativescript-worker-loader

Skintillion commented 3 years ago

Another thing that caused this for me, was not putting quotes around the keystore passwords on release.