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)
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 nativescriptnpm cache cleansudo 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 :
Notice that an important point was to remove
"nativescript-dev-android-snapshot": "^0.*.*",from dev dependanciesStep 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-passwordAnd 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) :
Same warnings :
Start of the issue by logcat :
OMG this worked, thanks… I have been struggling with this issue since yesterday afternoon, I’m glad I found this thread.
Cheers Jon