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.
Hi @terhoraj,
Thank you for reporting this issue.
I reviewed your case, however was unable to reproduce this problem, while build project in release mode with tns build android --release --key-store-path <path-to-your-keystore> --key-store-password <your-key-store-password> --key-store-alias <your-alias-name> --key-store-alias-password <your-alias-password>
command. I follow the steps described in the documentation here.
tns create test_app
tns build android --release --key-store-path C:\keystore\Telerik.keystore --key-store-password sample_password --key-store-alias Telerik --key-store-alias-password sample_password
command to generate APK file.<app_name>/platforms/android/build/outputs/apk/
folderRelated to the problem could you try to delete node_modules
and platforms
folder and to build in release mode again using tns build android --release --key-store-path <path-to-your-keystore> --key-store-password <your-key-store-password> --key-store-alias <your-alias-name> --key-store-alias-password <your-alias-password>
.
To investigate further the problem, it will help if you could give us the exact steps, which you are using for building the app.
Regards,
@tsonevn
Took testing further. Same project, same files, same keystore (Same everything) release build with Windows machine => release apk crashes every time.
Exactly same thing done using Mac => release apk to phone and it works.
What now?!
Reinstalling NativeScript did not help.
Hi @terhoraj,
After a further research on that matter, we are still unable to reproduce this strange behavior. To be able investigate further this problem, could you send us the package.json
file of your project and node
version. This information will help us to provide better solution for your case.
Thank you in advance for your cooperation,
Regards,
@tsonevn
Run tns prepare android
(no flags) before the build.
@tsonevn I ran into this myself and it would be great if the build command auto-prepared before initiating the build if it detects the targeted platform isn't prepared yet.
Hi @vbresults,
Thank you for writing us.
Using tns build android --release --key-store-path C:\keystore\Telerik.keystore --key-store-password sample_password --key-store-alias Telerik --key-store-alias-password sample_password
will auto prepare the project and you do not need to do it manually. We will upgrade the article and will remove the extra step from the documentation.
Update:
edited article with PR #622
Regards,
@tsonevn
Hmm seeing the same problem over here...
package.json:
{
"description": "test Application",
"license": "",
"readme": "",
"repository": "",
"nativescript": {
"id": "org.nativescript.test",
"tns-android": {
"version": "2.4.1"
}
},
"dependencies": {
"@angular/common": "2.3.0",
"@angular/compiler": "2.3.0",
"@angular/core": "2.3.0",
"@angular/forms": "2.3.0",
"@angular/http": "2.3.0",
"@angular/platform-browser": "2.3.0",
"@angular/platform-browser-dynamic": "2.3.0",
"@angular/router": "3.3.0",
"nativescript-angular": "1.2.0",
"nativescript-angular-snapshot": "1.2.0-5.2.361-1",
"nativescript-geolocation": "^0.0.17",
"nativescript-gif": "^1.0.8",
"nativescript-google-maps-sdk": "^1.4.1",
"nativescript-phone": "^1.2.3",
"nativescript-platform-css": "^1.3.0",
"nativescript-vibrate": "^1.1.2",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.1",
"tns-core-modules": "2.4.2",
"tns-platform-declarations": "^2.4.2"
},
"devDependencies": {
"babel-traverse": "6.20.0",
"babel-types": "6.20.0",
"babylon": "6.14",
"lazy": "1.0.11",
"nativescript-dev-android-snapshot": "^0.*.*",
"nativescript-dev-typescript": "^0.3.4",
"typescript": "^2.1.4",
"zone.js": "^0.7.2"
}
}
When the app is being compiled, there is a warning in the middle of it all:
The "nativescript-angular" and "tns-core-modules" packages and their dependencies have been deleted from the final assets.
Application will now use package "[email protected]" which includes these packages in precompiled form instead.
Two inconsistencies there:
Ok, its been what, an hour. I don't know if you fellas actually did something there or what, but my last compilation weighted 13.8 MB which crashed. Now, I tried to recompile it again (naturally deleting node_modules and platforms folders, as always), and now it weighs 16.7 MB and doesn't crash, it works.
I do have exactly the same issue, how can I manage to have this fixed ?
thanks !
@echap try removing platforms and node_modules folders and then re-run the command for creating release build.
@NickIliev Exactly what I've done, still same issue. Still not working. I get you a logcat asap.
```
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 "[email protected]" 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
Hi @echap,
Could you share the package.json
file of your app?
Regards,
@tsonevn
Sure @tsonevn ,
{
"name": "Ivy",
"version": "1.0.0",
"description": "A NativeScript-built iOS and Android app for drivers",
"keywords": [
"KEYWORD"
],
"author": "OUR TEAM",
"license": "Proprietary",
"homepage": "https://www.hubup.fr",
"nativescript": {
"id": "fr.hubup.ivy.demo",
"tns-ios": {
"version": "2.4.0"
},
"tns-android": {
"version": "2.4.1"
}
},
"dependencies": {
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/core": "2.1.2",
"@angular/forms": "2.1.2",
"@angular/http": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/router": "3.1.2",
"moment": "^2.15.1",
"nativescript-angular": "1.1.3",
"nativescript-angular-snapshot": "1.1.3-5.2.361",
"nativescript-audio": "^2.0.6",
"nativescript-background-http": "^2.3.0",
"nativescript-geolocation": "0.0.13",
"nativescript-google-maps-sdk": "git+https://github.com/hubupfr/nativescript-google-maps-sdk.git",
"nativescript-google-maps-utils": "git+https://github.com/hubupfr/nativescript-google-maps-utils.git",
"nativescript-pdf-view": "^1.2.0",
"nativescript-permissions": "^1.2.0",
"nativescript-phone": "^1.2.0",
"nativescript-plugin-firebase": "^3.8.4",
"nativescript-ripple": "^1.0.1",
"nativescript-snackbar": "^1.1.4",
"nativescript-swiss-army-knife": "1.0.7",
"nativescript-telerik-ui": "^1.4.1",
"nativescript-theme-core": "^0.2.1",
"reflect-metadata": "~0.1.8",
"rxjs": "5.0.0-beta.12",
"tns-core-modules": "2.4.0"
},
"devDependencies": {
"babel-traverse": "6.19.0",
"babel-types": "6.19.0",
"babylon": "6.14.1",
"lazy": "1.0.11",
"nativescript-dev-android-snapshot": "^0.*.*",
"nativescript-dev-typescript": "^0.3.2",
"typescript": "^2.0.10",
"zone.js": "~0.6.21"
}
}
And my tns --version
returns 2.4.0
(for my global install package)
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 [email protected]
(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 :+1:
OMG this worked, thanks... I have been struggling with this issue since yesterday afternoon, I'm glad I found this thread.
Cheers
Jon
I was able to rollback my tns
version (to 2.5.0, was 2.5.2) using the steps you mentioned.
Even with tns-core-modules
using a higher version (2.5.1) than nativescript
itself, the app built for release and didn't crash.
I also had to rollback tns
to version 2.5.0 from 2.5.1 for this to work.
Thanks!
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.
Hi @terhoraj,
After a further research on that matter, we are still unable to reproduce this strange behavior. To be able investigate further this problem, could you send us the
package.json
file of your project andnode
version. This information will help us to provide better solution for your case.Thank you in advance for your cooperation,
Regards,
@tsonevn
i've the same error that i solved by adding --bundle to the builde commande.
nb: app crashes after installation
hi @echap
i have the same problem but your methode not fonctione for me. can you help me?
Most helpful comment
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 [email protected]
(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-password
And you're done. The builded apk is not crashing at launch :+1: