Project doesn't launch after run tns run android --bundle


#1

Hi! I have an app using coding sharing with angular, but when I try to run the app I got the next error:

Executing before-prepareJSApp hook from C:\Ideas\Source\b2bAngular\hooks\before-prepareJSApp\nativescript-dev-webpack.js
Project successfully prepared (Android)
Executing after-prepare hook from C:\Ideas\Source\b2bAngular\hooks\after-prepare\nativescript-dev-webpack.js
Refreshing application...
Successfully synced application org.nativescript.ngsample on device c1f7d849.
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.ngsample/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
System.err: Calling js method onCreate failed
System.err:
System.err: TypeError: Cannot read property 'create' of undefined
System.err: File: "file:///data/data/org.nativescript.ngsample/files/app/vendor.js, line: 12298, column: 14
System.err:
System.err: StackTrace:
System.err:     Frame: function:'', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 12298, column: 15
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame-common.js.FrameBase.navigate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 19821, column: 30
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 21059, column: 30
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 20918, column: 14
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/activity.js.NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 18917, column: 25
System.err:
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2684)
System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2751)
System.err:     at android.app.ActivityThread.-wrap12(ActivityThread.java)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1496)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6186)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
System.err: Caused by: com.tns.NativeScriptException:
System.err: Calling js method onCreate failed
System.err:
System.err: TypeError: Cannot read property 'create' of undefined
System.err: File: "file:///data/data/org.nativescript.ngsample/files/app/vendor.js, line: 12298, column: 14
System.err:
System.err: StackTrace:
System.err:     Frame: function:'', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 12298, column: 15
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame-common.js.FrameBase.navigate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 19821, column: 30
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 21059, column: 30
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 20918, column: 14
System.err:     Frame: function:'push.../node_modules/tns-core-modules/ui/frame/activity.js.NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 18917, column: 25
System.err:
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:983)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:967)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:959)
System.err:     at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18)
System.err:     at android.app.Activity.performCreate(Activity.java:6684)
System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2637)
System.err:     ... 9 more

Any help is appreciated!


#2

Have you defined a custom activity?


#3

No, I haven’t. I just followed the steps in the documentation, after that I checked that the web project was working with npm start. And then I tried to test the app, and I got that error


#4

Can you try creating a new app and see if issue is reproduced there.
If not this must be something specific to your project and we may need a reproducible code to debug further.


#5

Now it is working. I started the process again, but this time I didn’t execute the update-ns-webpack script and it worked.

I tried to create a new project executing that script and it didn’t work, but when I created a new project without executing it, everything worked perfect. So I think is something with that script.

Thank you so much!!