Nativescript-angular: Android crash on release build, not debug - Failed to find module relative to: app/

Created on 24 Mar 2017  路  2Comments  路  Source: NativeScript/nativescript-angular

Having a strange issue where my app works fine on devices when doing

tns run android

but as soon as I try to do a release build using tns run android --release along with key store params I'm getting the 'Unfortunately, APP_NAME has stopped'.

Here's the error from logcat:

AndroidRuntime: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
03-24 11:05:54.641 12143 12143 E AndroidRuntime:
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Error calling module function
03-24 11:05:54.641 12143 12143 E AndroidRuntime:
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Error calling module function
03-24 11:05:54.641 12143 12143 E AndroidRuntime:
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Error: com.tns.NativeScriptException: Failed to find module: "./_helper/dialog", relative to: app/
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.tns.Module.resolvePathHelper(Module.java:159)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.tns.Module.resolvePath(Module.java:60)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.tns.Runtime.runModule(Native Method)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.tns.Runtime.runModule(Runtime.java:580)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.tns.Runtime.run(Runtime.java:574)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: android.app.ActivityThread.handleBindApplication(ActivityThread.java:6321)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: android.app.ActivityThread.access$1800(ActivityThread.java:222)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: android.os.Handler.dispatchMessage(Handler.java:102)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: android.os.Looper.loop(Looper.java:158)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: android.app.ActivityThread.main(ActivityThread.java:7229)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: java.lang.reflect.Method.invoke(Native Method)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
03-24 11:05:54.641 12143 12143 E AndroidRuntime: File: ", line: 1, column: 265
03-24 11:05:54.641 12143 12143 E AndroidRuntime:
03-24 11:05:54.641 12143 12143 E AndroidRuntime: StackTrace:
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Frame: function:'require', file:'', line: 1, column: 266
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Frame: function:'', file:'file:///data/data/my.app.name/files/app/app.module.js', line: 26, column: 16
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Frame: function:'require', file:'', line: 1, column: 266
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Frame: function:'', file:'file:///data/data/my.app.name/files/app/index.js', line: 8, column: 20
03-24 11:05:54.641 12143 12143 E AndroidRuntime: Frame: function:'require', file:'', line: 1, column: 266

So the problem is Failed to find module: "./_helper/dialog", relative to: app/ even though the debug version works fine.

Main parts of package.json:

"android": {
"v8Flags": "--expose_gc"
},
"dependencies": {
"@angular/common": "~2.4.3",
"@angular/compiler": "~2.4.3",
"@angular/core": "~2.4.3",
"@angular/forms": "~2.4.3",
"@angular/http": "~2.4.3",
"@angular/platform-browser": "~2.4.3",
"@angular/platform-browser-dynamic": "~2.4.3",
"@angular/router": "~3.4.3",
"email-validator": "1.0.4",
"nativescript-angular": "1.4.1",
"nativescript-angular-snapshot": "1.4.1-5.5.372.32-1",
"nativescript-calendar": "^1.2.1",
"nativescript-cardview": "^1.3.2",
"nativescript-email": "^1.4.0",
"nativescript-iqkeyboardmanager": "1.0.1",
"nativescript-ng2-fonticon": "^1.3.4",
"nativescript-phone": "^1.2.4",
"nativescript-social-share": "1.3.1",
"nativescript-theme-core": "^1.0.2",
"nativescript-toast": "1.4.5",
"nativescript-unit-test-runner": "^0.3.3",
"nativescript-web-image-cache": "^3.4.0",
"reflect-metadata": "0.1.8",
"rxjs": "~5.0.1",
"tns-core-modules": "^2.6.0-2017-02-08-5576",
"tns-platform-declarations": "^2.5.0",
"ts-md5": "1.2.0"
},
"devDependencies": {
"babel-traverse": "6.9.0",
"babel-types": "6.10.0",
"babylon": "6.8.1",
"codelyzer": "3.0.0-beta.0",
"filewalker": "0.1.2",
"jasmine-core": "2.4.1",
"karma": "1.2.0",
"karma-jasmine": "1.0.2",
"karma-nativescript-launcher": "0.4.0",
"lazy": "1.0.11",
"nativescript-dev-typescript": "0.3.7",
"nativescript-dev-android-snapshot": "^0..",
"tslint": "4.4.2",
"typescript": "~2.1.0",
"zone.js": "~0.7.2"
}

Line from app.module.ts:
import { DialogHelper } from "./_helper/dialog";

Line from app.module.js:
var dialog_1 = require("./_helper/dialog");

But as you can see here, the file is there:

app

The dialog.js file is also present in platforms\android\src\main\assets\app\_helper after the build has taken place.

Release build on iOS works fine too. I've seen bug reports on this type of error before but they all relate to node modules issues and not application code.

I'm on nativescript 2.5.3 with tns-core-modules 2.5.2

Any help would be greatly appreciated!

Most helpful comment

Appears this was all down to having underscores in the directory names.. strange as it only failed with the release builds.

Sorted now after removing all underscores

All 2 comments

Appears this was all down to having underscores in the directory names.. strange as it only failed with the release builds.

Sorted now after removing all underscores

This error occurs to me, what should I do?

Was this page helpful?
0 / 5 - 0 ratings