NativeScript: Release build crashes at start, debug works. NS 2.4.1

Like title says debug build works and release build crashes. I’m only using/building for Android. here my tns info: │ nativescript │ 2.4.1 │ 2.4.1 │ Up to date │ tns-core-modules │ 2.4.1 │ 2.4.1 │ Up to date │ tns-android │ 2.4.1 │ 2.4.1 │ Up to date

Here’s logcat output got using Android Studios logcat (I replaced package names for reason):

`12-07 10:12:57.108 5232-5232/? E/AndroidRuntime: FATAL EXCEPTION: main Process: PACKAGENAME, PID: 5232 java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

                                             Error calling module function 
                                             
                                             Error: com.tns.NativeScriptException: Failed to find module: "ui/frame/activity", relative to: app/tns_modules/
                                                 com.tns.Module.resolvePathHelper(Module.java:159)
                                                 com.tns.Module.resolvePath(Module.java:60)
                                                 com.tns.Runtime.runModule(Native Method)
                                                 com.tns.Runtime.runModule(Runtime.java:514)
                                                 com.tns.RuntimeHelper.initRuntime(RuntimeHelper.java:154)
                                                 com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:15)
                                                 android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
                                                 android.app.ActivityThread.handleBindApplication(ActivityThread.java:6422)
                                                 android.app.ActivityThread.access$1800(ActivityThread.java:229)
                                                 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
                                                 android.os.Handler.dispatchMessage(Handler.java:102)
                                                 android.os.Looper.loop(Looper.java:148)
                                                 android.app.ActivityThread.main(ActivityThread.java:7325)
                                                 java.lang.reflect.Method.invoke(Native Method)
                                                 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                                             File: "<unknown>, line: 1, column: 265
                                             
                                             StackTrace: 
                                             	Frame: function:'require', file:'', line: 1, column: 266
                                             	Frame: function:'', file:'/data/data/PACKAGENAME/files/app/tns-java-classes.js', line: 1, column: 61
                                             	Frame: function:'require', file:'', line: 1, column: 266`

app/tns_modules/ folder does not even exists so why it’s trying to find some module from there and why it’s not complaining about that with debug build.

I’m constantly trying to find what causes this, I update this issue if I find a solution.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 21 (5 by maintainers)

Most upvoted comments

Okay, thanks to @tsonevn we managed to find a working solution :

Step 1 : update tns version to 2.4.2 globally sudo npm uninstall -g nativescript npm cache clean sudo npm install -g nativescript@2.4.2

(I had no permission issue but it may appear in some other cases I guess)

Step 2 : updating core dependancies to this :

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.sampleprojectng2"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/router": "3.2.1",
    "nativescript-angular": "1.2.0",
    "nativescript-theme-core": "^0.2.1",
    "reflect-metadata": "~0.1.8",
    "rxjs": "5.0.0-beta.12",
    "tns-core-modules": "2.4.3"
  },
  "devDependencies": {
    "nativescript-dev-typescript": "^0.3.2",
    "typescript": "~2.0.10",
    "zone.js": "~0.6.21"
  }
}

Notice that an important point was to remove "nativescript-dev-android-snapshot": "^0.*.*", from dev dependancies

Step 3 : Clear your ng project rm -rf node_modules/ platforms/ hooks/

Step 4 : generate your stuff tns build android --release --key-store-path C:\keystore\Telerik.keystore --key-store-password sample_password --key-store-alias Telerik --key-store-alias-password

And you’re done. The builded apk is not crashing at launch 👍

I had a similar problem, all debug builds worked and release builds crashed.

logcat told me: Error: com.tns.NativeScriptException: Failed to find module: "nativescript-angular", relative to: app/tns_modules/

In one of my .ts files I did: import {RouterExtensions} from "nativescript-angular"; instead of: import {RouterExtensions} from "nativescript-angular/router";

Maybe this helps.

My steps (needless to say, my app in debug works like a charm) :

me@me:~/projects/nativescript-ivy$ rm -rf node_modules/
me@me:~/projects/nativescript-ivy$ rm -rf platforms/
me@me:~/projects/nativescript-ivy$ tns build android --release --key-store-path <xx> --key-store-password <xx> --key-store-alias <xx> --key-store-alias-password <xx> 

Same warnings :

The "nativescript-angular" and "tns-core-modules" packages and their dependencies have been deleted from the final assets.
Application will now use package "nativescript-angular-snapshot@latest-1.1.3-5.2.361" which includes these packages in precompiled form instead.

Start of the issue by logcat :

12-20 10:05:51.704  5146  5146 D TNS.Native: Snapshot library read 0xc59fd008 (9970064B).
12-20 10:05:51.800  5146  5146 D TNS.Native: V8 version 5.2.361
12-20 10:05:51.875  5146  5146 D TNS.Native: lenNodes=87156, lenNames=834339, lenValues=1048442
12-20 10:05:51.875  5146  5146 D TNS.Native: time=2
12-20 10:05:52.321  5146  5146 D AndroidRuntime: Shutting down VM
12-20 10:05:52.326  5146  5146 W System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
12-20 10:05:52.326  5146  5146 W System.err: 
12-20 10:05:52.326  5146  5146 W System.err: Error calling module function 
12-20 10:05:52.326  5146  5146 W System.err: 
12-20 10:05:52.326  5146  5146 W System.err: Error calling module function 
12-20 10:05:52.326  5146  5146 W System.err: 
12-20 10:05:52.326  5146  5146 W System.err: Error calling module function 
12-20 10:05:52.326  5146  5146 W System.err: 
12-20 10:05:52.326  5146  5146 W System.err: Error calling module function 
12-20 10:05:52.326  5146  5146 W System.err: 
12-20 10:05:52.326  5146  5146 W System.err: Error: com.tns.NativeScriptException: Failed to find module: "nativescript-angular", relative to: app/tns_modules/
12-20 10:05:52.327  5146  5146 W System.err:     com.tns.Module.resolvePathHelper(Module.java:159)
12-20 10:05:52.327  5146  5146 W System.err:     com.tns.Module.resolvePath(Module.java:60)
12-20 10:05:52.327  5146  5146 W System.err:     com.tns.Runtime.runModule(Native Method)
12-20 10:05:52.327  5146  5146 W System.err:     com.tns.Runtime.runModule(Runtime.java:514)
12-20 10:05:52.327  5146  5146 W System.err:     com.tns.Runtime.run(Runtime.java:509)
12-20 10:05:52.327  5146  5146 W System.err:     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
12-20 10:05:52.327  5146  5146 W System.err:     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
12-20 10:05:52.327  5146  5146 W System.err:     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
12-20 10:05:52.327  5146  5146 W System.err:     android.app.ActivityThread.-wrap2(ActivityThread.java)
12-20 10:05:52.327  5146  5146 W System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
12-20 10:05:52.327  5146  5146 W System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
12-20 10:05:52.327  5146  5146 W System.err:     android.os.Looper.loop(Looper.java:154)
12-20 10:05:52.327  5146  5146 W System.err:     android.app.ActivityThread.main(ActivityThread.java:6119)
12-20 10:05:52.327  5146  5146 W System.err:     java.lang.reflect.Method.invoke(Native Method)
12-20 10:05:52.327  5146  5146 W System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
12-20 10:05:52.327  5146  5146 W System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
12-20 10:05:52.327  5146  5146 W System.err: File: "<unknown>, line: 1, column: 265
12-20 10:05:52.327  5146  5146 W System.err: 
12-20 10:05:52.327  5146  5146 W System.err: StackTrace: 
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'require', file:'', line: 1, column: 266
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'', file:'/data/data/fr.hubup.ivy.demo/files/app/bundles/geotrackingBundle/views/record/record.component.js', line: 6, column: 30
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'require', file:'', line: 1, column: 266
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'', file:'/data/data/fr.hubup.ivy.demo/files/app/app.routing.js', line: 3, column: 26
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'require', file:'', line: 1, column: 266
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'', file:'/data/data/fr.hubup.ivy.demo/files/app/app.module.js', line: 7, column: 21
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'require', file:'', line: 1, column: 266
12-20 10:05:52.327  5146  5146 W System.err: 	Frame: function:'', file:'/data/data/fr.hubup.ivy.demo/files/app/main.js', line: 11, column: 20

OMG this worked, thanks… I have been struggling with this issue since yesterday afternoon, I’m glad I found this thread.

Cheers Jon