App crashes when deployed on actual device but runs okay in emulator


#1

I have an app that connects to an API. It works okay when running it in an emulator Genymotion/Android Studio but when I generated the APK and installed on android phone it crashes after seeing the splash screen then it will display a message “Unfortunately, myApp has stopped”

Is there a way to catch the error behind the crash so I can check which section in my code is causing it?

Thank you guys.


#2

Hi @mikevg08
Can you please provide more info on the device on which you are trying to run the app?
Which Android API Level is it running on?


#3

Hi @multishiv19

Thanks for your response.

The emulator is running on Android 4.4.4 API 19 and works fine in there but when I install the APK to my Android device Samsung Galaxy A7 5.0.2 it crashes after the splash screen.

It is working on both before but when I updated the code to call the API using @angular/http that’s when it start not to work on the actual device.

import { Injectable } from '@angular/core';
import { Http, HttpModule, ConnectionBackend, Headers, Response, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'
import { Config } from '../app.config';

@Injectable()
export class ApiService {
	post(operation: string, data: any) {
		 let body = (data.payload);
		 let headers = new Headers({ 'Content-Type': 'application/json' });
         let options = new RequestOptions({ headers: headers });
         return this.http.post(Config.api.endpoint + operation, body, options);
	}
}

#4

Is there a way to trace the error why it is crashing? Thanks.


#5

Did you try tns debug android ?


#6

Yes I tried debug and run and it works fine on emulator but when generate and APK and install on a device it crashes on launch :frowning:


#7

You can inspect the device logs by running adb logcat, there should be some information related to the crash that you are experiencing. Feel free to copy-paste the logs, better yet use pastebin, if possible.

To get the log do the following:

  • connect just the usb device, turn off any other emulators
  • execute adb logcat -c to clean the device log
  • run application, let it crash
  • dump log into a file and share its content via any online text-sharing service (pastebin.com) adb logcat -d > log.txt

#8

Thank you @Pete.K

Here’s the log I got from logcat:

E/SELinux (12944): [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
I/art     (12944): Late-enabling -Xcheck:jni
D/TimaKeyStoreProvider(12944): TimaSignature is unavailable
D/ActivityThread(12944): Added TimaKeyStore provider
I/TNS.Native(12944): NativeScript Runtime Version 3.2.0, commit 98501b79c76cc2cf4d01f6111eab4cdfc42913df
D/TNS.Native(12944): JNI_ONLoad
D/TNS.Native(12944): JNI_ONLoad END
E/File    (12944): fail readDirectory() errno=2
D/TNS.Native(12944): Failed to load snapshot: dlopen failed: library "libsnapshot.so" not found
D/TNS.Native(12944): V8 version 5.5.372.32
D/TNS.Native(12944): lenNodes=78600, lenNames=872505, lenValues=1076317
D/TNS.Native(12944): time=5
D/AndroidRuntime(12944): Shutting down VM
W/System.err(12944): java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5286)
W/System.err(12944): 	at android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944): 	at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944): 	at android.os.Looper.loop(Looper.java:145)
W/System.err(12944): 	at android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944): 	at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): Caused by: com.tns.NativeScriptException: 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error calling module function 
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): Error: com.tns.NativeScriptException: Failed to find module: "../../_helpers/util", relative to: app/components/schooldays/
W/System.err(12944):     com.tns.Module.resolvePathHelper(Module.java:146)
W/System.err(12944):     com.tns.Module.resolvePath(Module.java:55)
W/System.err(12944):     com.tns.Runtime.runModule(Native Method)
W/System.err(12944):     com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944):     com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944):     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944):     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944):     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944):     android.app.ActivityThread.access$1600(ActivityThread.java:181)
W/System.err(12944):     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
W/System.err(12944):     android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12944):     android.os.Looper.loop(Looper.java:145)
W/System.err(12944):     android.app.ActivityThread.main(ActivityThread.java:6220)
W/System.err(12944):     java.lang.reflect.Method.invoke(Native Method)
W/System.err(12944):     java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(12944):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
W/System.err(12944):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
W/System.err(12944): File: "<unknown>, line: 1, column: 265
W/System.err(12944): StackTrace: 
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/components/schooldays/schooldays.js', line: 16, column: 14
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.routing.js', line: 6, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/app.module.js', line: 5, column: 21
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	Frame: function:'', file:'file:///data/data/org.nativescript.mike/files/app/main.js', line: 5, column: 20
W/System.err(12944): 	Frame: function:'require', file:'', line: 1, column: 266
W/System.err(12944): 	at com.tns.Runtime.runModule(Native Method)
W/System.err(12944): 	at com.tns.Runtime.runModule(Runtime.java:530)
W/System.err(12944): 	at com.tns.Runtime.run(Runtime.java:522)
W/System.err(12944): 	at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
W/System.err(12944): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
W/System.err(12944): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5283)
W/System.err(12944): 	... 9 more
I/Process (12944): Sending signal. PID: 12944 SIG: 9

The error — com.tns.NativeScriptException: Failed to find module: “…/…/_helpers/util”, relative to: app/components/schooldays/ ----

this works fine when running on an emulator.


#9

Is it possible that my phone/device is looking for “…/…/_helpers/util” file which points to my computer’s directory path? That’s why it is working on emulator only? Here’s my directory structure:

MyApp
 -> app
   -> _api
   -> _directives
   -> _helpers
      -> util.ts

   -> _services
   -> components
      -> schooldays
  	     -> schooldays.ts

   -> fonts
   -> models
 -> hooks
 -> node_modules
 -> platforms

#10

Hey @mikevg08,

This is almost certainly a path issue based on that error, but I do find it’s odd that you’re only getting this on device.

In your schooldays.ts file how are you currently importing from utils.ts?


#11

Hi @tjvantoll,

This is how I am calling util.ts

import { Util } from '../../_helpers/util';

Yeah it’s really weird that it is only happening on device. is there something that I need to set like a path or something in a config file before generating an APK?

If I remove those file references it works fine on the device.

Thanks :slight_smile:


#12

Weird it works on the emulator but not the device, I might sound silly but maybe try to change _helpers name to just helpers. You don’t know as some devices greys out invalid characters.

or try to load it relative to the app bundle like in here https://docs.nativescript.org/runtimes/require#loading-files-from-the-app-bundle


#13

Hey @mikevg08,

This is bizarre. I personally see no reason why that import doesn’t work on device. You shouldn’t have to configure global paths or anything like that. Hopefully someone else from the community or from the team has ideas here.

As a really long shot, you might want to check your platforms/android/src/main/assets/app folder, and make sure you have the file structure you expect in there. Maybe some build tool is messing with your file/folder structure in an unexpected way.


#14

Good news guys!!! @ganas is correct! I have renamed the folders that has underscore in front of the folder name and it worked like a charm!

Thank you so much for your help guys, cheers! :slight_smile: