NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
518 stars 136 forks source link

NS/Android Unable to create application com.tns.NativeScriptApplication: Error calling module function: Unexpected string #1804

Closed z7jzk closed 5 months ago

z7jzk commented 5 months ago

Environment

Describe the bug I am able to successfully build and evaluate locally on a physical device with ns debug android. I am also able to successfully build the application for production release with ns build android --release --key-store-path path/keystore.jks --key-store-password password --key-store-alias keyalias --key-store-alias-password keyaliaspassword --aab --copy-to dist/app-bundle.aab. Once I deploy the application to the Play Store for internal testing (or production release), the app crashes on launch with the following error:

Exception java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function 
Cannot compile /data/data/com.gnarlab.gnarlink/files/app/vendor.js
SyntaxError: Unexpected string
File: (file:///data/data/com.domain.appname/files/app/vendor.js:2:1947055)
StackTrace: 
require(:1:266)
  at __webpack_require__.f.require (file:///data/data/com.domain.appname/files/app/runtime.js:1:1486)

I've tried deleting node_modules, platforms/android, and hooks while also reinstalling packages and rebuilding numerous times. I've removed additional plugins such as "@nativescript-community/ble", "@nativescript-community/perms", "@nativescript/iqkeyboardmanager", and "nativescript-gif" and going through same steps of deleting packages/platforms and rebuilding, also with no luck.

vallemar commented 5 months ago

Hi @z7jzk ! try to run for replication in local as: ns run android --env-production.

Does the error reproduce? Do you have more details about the error? Do you have more details in the android studio logs?

z7jzk commented 5 months ago

@vallemar,

Running the replication in local with ns run android --env-production does not reproduce the same error, it installs on device and runs as expected.

z7jzk commented 5 months ago

I just realized I needed to run this command: ns run android --env.production and by doing so I encountered this error:

  System.err: An uncaught Exception occurred on "main" thread.
  System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function
  System.err: Cannot compile /data/data/com.domain.appname/files/app/vendor.js
  System.err: SyntaxError: Unexpected string
  System.err: File: (file: src/webpack:/appname/node_modules/@angular/core/fesm2022/core.mjs:6464:4)
  System.err:
  System.err: StackTrace:
  System.err: require(:1:266)
  System.err:   at __webpack_require__.f.require(file: src/webpack:/appname/webpack/runtime/require chunk loading:34:7)
  System.err:   at (file: src/webpack:/appname/webpack/runtime/get javascript chunk filename:4:32)
  System.err:   at __webpack_require__.e(file:///data/data/com.domain.appname/files/app/runtime.js:1:915)
  System.err:   at __webpack_require__.X(file: src/webpack:/appname/webpack/runtime/startup entrypoint:7:1)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209470)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209702)
  System.err:   at require(:1:266)
  System.err:
  System.err:
  System.err: SyntaxError: Unexpected string
  System.err: File: (<unknown>:1:265)
  System.err:
  System.err: StackTrace:
  System.err: require(:1:266)
  System.err:   at __webpack_require__.f.require(file: src/webpack:/appname/webpack/runtime/require chunk loading:34:7)
  System.err:   at (file: src/webpack:/appname/webpack/runtime/get javascript chunk filename:4:32)
  System.err:   at __webpack_require__.e(file:///data/data/com.domain.appname/files/app/runtime.js:1:915)
  System.err:   at __webpack_require__.X(file: src/webpack:/appname/webpack/runtime/startup entrypoint:7:1)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209470)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209702)
  System.err:   at require(:1:266)
  System.err:
  System.err:
  System.err: SyntaxError: Unexpected string
  System.err:
  System.err: StackTrace:
  System.err: require(:1:266)
  System.err:   at __webpack_require__.f.require(file: src/webpack:/appname/webpack/runtime/require chunk loading:34:7)
  System.err:   at (file: src/webpack:/appname/webpack/runtime/get javascript chunk filename:4:32)
  System.err:   at __webpack_require__.e(file:///data/data/com.domain.appname/files/app/runtime.js:1:915)
  System.err:   at __webpack_require__.X(file: src/webpack:/appname/webpack/runtime/startup entrypoint:7:1)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209470)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209702)
  System.err:   at require(:1:266)
  System.err:   at __webpack_require__.f.require(file: src/webpack:/appname/webpack/runtime/require chunk loading:34:7)
  System.err:   at (file: src/webpack:/appname/webpack/runtime/get javascript chunk filename:4:32)
  System.err:   at __webpack_require__.e(file:///data/data/com.domain.appname/files/app/runtime.js:1:915)
  System.err:   at __webpack_require__.X(file: src/webpack:/appname/webpack/runtime/startup entrypoint:7:1)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209470)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209702)
  System.err:   at require(:1:266)
  System.err:
  System.err:
  System.err: SyntaxError: Unexpected string
  System.err: File: (<unknown>:1:265)
  System.err:
  System.err: StackTrace:
  System.err: require(:1:266)
  System.err:   at __webpack_require__.f.require(file: src/webpack:/appname/webpack/runtime/require chunk loading:34:7)
  System.err:   at (file: src/webpack:/appname/webpack/runtime/get javascript chunk filename:4:32)
  System.err:   at __webpack_require__.e(file:///data/data/com.domain.appname/files/app/runtime.js:1:915)
  System.err:   at __webpack_require__.X(file: src/webpack:/appname/webpack/runtime/startup entrypoint:7:1)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209470)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209702)
  System.err:   at require(:1:266)
  System.err:
  System.err:
  System.err: SyntaxError: Unexpected string
  System.err:   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7264)
  System.err:   at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
  System.err:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2292)
  System.err:   at android.os.Handler.dispatchMessage(Handler.java:106)
  System.err:   at android.os.Looper.loopOnce(Looper.java:240)
  System.err:   at android.os.Looper.loop(Looper.java:351)
  System.err:   at android.app.ActivityThread.main(ActivityThread.java:8423)
  System.err:   at java.lang.reflect.Method.invoke(Native Method)
  System.err:   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
  System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
  System.err: Caused by: com.tns.NativeScriptException: Error calling module function
  System.err: Cannot compile /data/data/com.domain.appname/files/app/vendor.js
  System.err: SyntaxError: Unexpected string
  System.err: File: (file: src/webpack:/appname/node_modules/@angular/core/fesm2022/core.mjs:6464:4)
  System.err:
  System.err: StackTrace:
  System.err: require(:1:266)
  System.err:   at __webpack_require__.f.require(file: src/webpack:/appname/webpack/runtime/require chunk loading:34:7)
  System.err:   at (file: src/webpack:/appname/webpack/runtime/get javascript chunk filename:4:32)
  System.err:   at __webpack_require__.e(file:///data/data/com.domain.appname/files/app/runtime.js:1:915)
  System.err:   at __webpack_require__.X(file: src/webpack:/appname/webpack/runtime/startup entrypoint:7:1)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209470)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209702)
  System.err:   at require(:1:266)
  System.err:
  System.err:
  System.err: SyntaxError: Unexpected string
  System.err: File: (<unknown>:1:265)
  System.err:
  System.err: StackTrace:
  System.err: require(:1:266)
  System.err:   at __webpack_require__.f.require(file: src/webpack:/appname/webpack/runtime/require chunk loading:34:7)
  System.err:   at (file: src/webpack:/appname/webpack/runtime/get javascript chunk filename:4:32)
  System.err:   at __webpack_require__.e(file:///data/data/com.domain.appname/files/app/runtime.js:1:915)
  System.err:   at __webpack_require__.X(file: src/webpack:/appname/webpack/runtime/startup entrypoint:7:1)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209470)
  System.err:   at (file:///data/data/com.domain.appname/files/app/bundle.js:1:209702)
  System.err:   at require(:1:266)
  System.err:
  System.err:
  System.err: SyntaxError: Unexpected string
  System.err:   at com.tns.Runtime.runModule(Native Method)
  System.err:   at com.tns.Runtime.runModule(Runtime.java:688)
  System.err:   at com.tns.Runtime.run(Runtime.java:680)
  System.err:   at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
  System.err:   at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1285)
  System.err:   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7257)
  System.err:   ... 9 more
z7jzk commented 5 months ago

@vallemar, after deleting my package-lock.json and yarn.lock files, deleting node_modules, hooks, and platforms folders and reinstalling all packages and rebuilding, it seems that did the trick

vallemar commented 5 months ago

@z7jzk good! just for this you have the ns clean command