Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app crash when using npm modules #76

Closed
erik-sytnyk opened this issue May 10, 2016 · 5 comments
Closed

app crash when using npm modules #76

erik-sytnyk opened this issue May 10, 2016 · 5 comments

Comments

@erik-sytnyk
Copy link

On "angular-end" branch having exception below.

When comment out external package usages it works fine.

Exception message:

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Failed to find module: "email-validator", relative to: /app/tns_modules/
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5125)
at android.app.ActivityThread.access$1600(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1510)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: com.tns.NativeScriptException: Failed to find module: "email-validator", relative to: /app/tns_modules/
at com.tns.Module.resolvePathHelper(Module.java:220)
at com.tns.Module.resolvePath(Module.java:60)
at com.tns.Runtime.runModule(Native Method)
at com.tns.Runtime.runModule(Runtime.java:241)
at com.tns.Runtime.run(Runtime.java:235)
at com.tns.RuntimeHelper.initRuntime(RuntimeHelper.java:129)
at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:13)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5122)
... 9 more

@tjvantoll
Copy link
Contributor

Hey @yegor-sytnyk,

Sorry that you ran into issues here. Two ideas: first, did you make sure to include the --save flag when you ran npm install? That is, npm install email-validator --save. The NativeScript CLI looks for the dependency in the package.json before including the module in the app package.

Second, did you make sure to perform a full build after installing this package? The NativeScript CLI’s livesync command (at least at the moment), is not able to inject new npm modules into the app package. You must kill the livesync command with Ctrl+C, and then run tns run ios or tns run android for the new npm module to be properly injected.

Let me know how it goes.

@erik-sytnyk
Copy link
Author

Hi @tjvantoll

Thank you for instructions! Unfortunately, nothing helped until I have removed platform/hooks folders and have added android platform again. Now it works fine.

I've missed section of tutorial where you say that you have to run

tns run android --emulator
and then
tns livesync android --watch

I have assumed that it is like with webpack if you want to clean build you just run
webpack --watch
one more time

@tjvantoll
Copy link
Contributor

Thanks @yegor-sytnyk, glad you got this working. Yeah sometime rm -rf platforms/ hooks/ and tns install is the ultimate debugging step 😀

I actually have an open issue to consolidate our commands so that tns livesync essentially becomes the default experience. Feel free to vote on NativeScript/nativescript-cli#1366.

@bhargavakrishna
Copy link

                 I have a problem regarding to list in native app ,                                                                                                  

Total time: 1 mins 11.52 secs
Project successfully built
Successfully deployed on device with identifier '41aec819'.
chromium: [WARNING:server_connection_manager.cc(272)] ServerConnectionManager forcing SYNC_AUTH_ERROR
chromium: [WARNING:syncer_proto_util.cc(341)] Error posting from syncer: Response Code (bogus on error): -1 Content-Length (bogus on error): -1 S
erver Status: SYNC_AUTH_ERROR
JS: undefined
JS: Error: com.tns.NativeScriptException: Failed to find module: "data/observableArrayModule", relative to: /app/tns_modules/
JS: com.tns.Module.resolvePathHelper(Module.java:220)
JS: com.tns.Module.resolvePath(Module.java:60)
JS: com.tns.Runtime.callJSMethodNative(Native Method)
JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:865)
JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:730)
JS: com.tns.Runtime.callJSMethod(Runtime.java:716)
JS: com.tns.Runtime.callJSMethod(Runtime.java:697)
JS: com.tns.Runtime.callJSMethod(Runtime.java:687)
JS: com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(org.nativescript.widgets.Async$CompleteCallback.java)
JS: org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:465)
JS: org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:379)
JS: android.os.AsyncTask.finish(AsyncTask.java:632)
JS: android.os.AsyncTask.access$600(AsyncTask.java:177)
JS: android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
JS: android.os.Handler.dispatchMessage(Handler.java:102)
JS: android.os.Looper.loop(Looper.java:135)
JS: android.app.ActivityThread.main(ActivityThread.java:5233)
JS: java.lang.reflect.Method.invoke(Native Method)
JS: java.lang.reflect.Method.invoke(Method.java:372)
JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
chromium: [WARNING:server_connection_manager.cc(272)] ServerConnectionManager forcing SYNC_AUTH_ERROR

@Xtt45
Copy link

Xtt45 commented Dec 1, 2016

I had the same issue, what I did was just to open a new terminal and ran tns run android --emulator on the root folder of the project then it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants