Nativescript: Failed to find module "./Services/UserService"

Created on 5 Dec 2017  Â·  7Comments  Â·  Source: NativeScript/NativeScript

Hi,

I am getting this error only while building apk, when I run or debug in emulator or in actual device using USB it's working absolutely fine.. but when i build apk using tns build android / sidekick, it shows this error.

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 

Error calling module function 

Error calling module function 

Error calling module function 

Error: com.tns.NativeScriptException: Failed to find module: "./_Services/UserService", relative to: app/
    com.tns.Module.resolvePathHelper(Module.java:146)
    com.tns.Module.resolvePath(Module.java:55)
    com.tns.Runtime.runModule(Native Method)
    com.tns.Runtime.runModule(Runtime.java:530)
    com.tns.Runtime.run(Runtime.java:522)
    com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
    android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
    android.app.ActivityThread.handleBindApplication(ActivityThread.java:5455)
    android.app.ActivityThread.-wrap2(ActivityThread.java)
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1574)
    android.os.Handler.dispatchMessage(Handler.java:102)
    android.os.Looper.loop(Looper.java:163)
    android.app.ActivityThread.main(ActivityThread.java:6237)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/app.component.js', line: 4, column: 21
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/app.module.js', line: 8, column: 23
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/main.js', line: 5, column: 20
    Frame: function:'require', file:'', line: 1, column: 266


Error: com.tns.NativeScriptException: Failed to find module: "./_Services/UserService", relative to: app/
    com.tns.Module.resolvePathHelper(Module.java:146)
    com.tns.Module.resolvePath(Module.java:55)
    com.tns.Runtime.runModule(Native Method)
    com.tns.Runtime.runModule(Runtime.java:530)
    com.tns.Runtime.run(Runtime.java:522)
    com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
    android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
    android.app.ActivityThread.handleBindApplication(ActivityThread.java:5455)
    android.app.ActivityThread.-wrap2(ActivityThread.java)
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1574)
    android.os.Handler.dispatchMessage(Handler.java:102)
    android.os.Looper.loop(Looper.java:163)
    android.app.ActivityThread.main(ActivityThread.java:6237)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/app.component.js', line: 4, column: 21
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/app.module.js', line: 8, column: 23
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/main.js', line: 5, column: 20
    Frame: function:'require', file:'', line: 1, column: 266


Error: com.tns.NativeScriptException: Failed to find module: "./_Services/UserService", relative to: app/
    com.tns.Module.resolvePathHelper(Module.java:146)
    com.tns.Module.resolvePath(Module.java:55)
    com.tns.Runtime.runModule(Native Method)
    com.tns.Runtime.runModule(Runtime.java:530)
    com.tns.Runtime.run(Runtime.java:522)
    com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:19)
    android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
    android.app.ActivityThread.handleBindApplication(ActivityThread.java:5455)
    android.app.ActivityThread.-wrap2(ActivityThread.java)
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1574)
    android.os.Handler.dispatchMessage(Handler.java:102)
    android.os.Looper.loop(Looper.java:163)
    android.app.ActivityThread.main(ActivityThread.java:6237)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/app.component.js', line: 4, column: 21
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/app.module.js', line: 8, column: 23
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/org.socialstock.com/files/app/main.js', line: 5, column: 20
    Frame: function:'require', file:'', line: 1, column: 266

Please help

android

All 7 comments

Hi @kunaldodiya,
Thank you for contacting us.
Could you please send us sample project, which could be used for debugging?
It would e hard to investigate further this case without the actual code, where the problem could be reproduced.

Thank you in advance for your cooperation

[email protected]:kunaldodiya/sampleapp.git this is the source of my app, the problem is I have a Custom Logo component that is working either in Login or in CreateProfile component, but if I use in both it doesn't work at all.

Hi @kunaldodiya,
I am unable to access the project from the provided repository. Could you verify if the repository is public? if it is not please add me to the project while using the following email - nikolay.[email protected]

You are now a member, thanks for help again.

On Wed, Dec 6, 2017 at 3:07 PM, Nikolay Tsonev notifications@github.com
wrote:

Hi @kunaldodiya https://github.com/kunaldodiya,
I am unable to access the project from the provided repository. Could you
verify if the repository is public? if it is not please add me to the
project while using the following email - nikolay.[email protected]

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NativeScript/NativeScript/issues/5131#issuecomment-349585265,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG72Td3IzbkMlg5fjuO28Ld5CgDzFcpsks5s9mBTgaJpZM4Q1tRa
.

Hi @kunaldodiya,
I reviewed your case, however, was unable to reproduce the initial error, which you have reported Failed to find module "./Services/UserService".
Regarding the Logo component, the error, which was thrown in the console on my side was that the logo.component.htmland logo.style.css files were not found. To fix this you should add moduleId inside the @Component definition in the begging of logo.component.ts file. For example:

@Component({
    selector: 'Logo',
    moduleId: module.id,
    templateUrl: "./logo.component.html",
    styleUrls: ["./logo.style.css"]
})

The moduleId is needed while we are working with relative paths.

thanks,

solved it by exporting as module instead of component declaration :)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings