My nativescript application runs successfully in first run without any error, but when I save any file without any change, or small changes my app crashes whith below information.
08-24 13:32:36.684 3595 3595 E AndroidRuntime: at com.tns.Runtime.callJSMethodNative(Native Method) 08-24 13:32:36.684 3595 3595 E AndroidRuntime: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116) 08-24 13:32:36.684 3595 3595 E AndroidRuntime:
at com.tns.Runtime.callJSMethodImpl(Runtime.java:996) 08-24 13:32:36.684 3595 3595 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:983) 08-24 13:32:36.684 3595 3595 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:967) 08-24
13:32:36.684 3595 3595 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:959) System.err: com.tns.NativeScriptException: System.err: Calling js method onViewAttachedToWindow failed System.err: System.err: TypeError: Cannot read property 'onNavigatingTo'
of undefined System.err: File: "file:///data/data/org.nativescript.TekmoTs/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js, line: 262, column: 36 System.err: System.err: StackTrace: System.err: Frame: function:'FrameBase._onNavigatingTo',
file:'file:///data/data/org.nativescript.TekmoTs/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 262, column: 37 System.err: Frame: function:'FrameBase.performNavigation', file:'file:///data/data/org.nativescript.TekmoTs/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js',
line: 234, column: 14 System.err: Frame: function:'FrameBase._processNextNavigationEntry', file:'file:///data/data/org.nativescript.TekmoTs/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 227, column: 22 System.err: Frame: function:'Frame._processNextNavigationEntry',
file:'file:///data/data/org.nativescript.TekmoTs/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 138, column: 58 System.err: Frame: function:'Frame._onAttachedToWindow', file:'file:///data/data/org.nativescript.TekmoTs/files/app/tns_modules/tns-core-modules/ui/frame/frame.js',
line: 114, column: 14 System.err: Frame: function:'AttachListener.onViewAttachedToWindow', file:'file:///data/data/org.nativescript.TekmoTs/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 38, column: 27 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.gen.java.lang.Object_frame_32_36_AttachListener.onViewAttachedToWindow(Object_frame_32_36_AttachListener.java:17) System.err: at android.view.View.dispatchAttachedToWindow(View.java:18358)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761) System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460) System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183) System.err:
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949) System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:761) System.err: at android.view.Choreographer.doFrame(Choreographer.java:696) System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
System.err: at android.os.Handler.handleCallback(Handler.java:873) System.err: at android.os.Handler.dispatchMessage(Handler.java:99) System.err: at android.os.Looper.loop(Looper.java:193) System.err: at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
the app-root.xml file's content is as below:
<Frame defaultPage="views/contact-us/contact-us">
</Frame>
and file stucture is as below:
├───app
│ ├───App_Resources
│ │ ├───Android
│ │ └───iOS
│ └───views
│ ├───about
│ ├───contact-us
│ └───home
├───hooks
...
the contact-us.xml file's content is also is as below:
<Page xmlns="http://www.nativescript.org/tns.xsd" navigatingTo="onNavigatedTo">
<ScrollView>
<StackLayout>
<Label text="Contact us by submitting a message below." textWrap="true" />
<TextField hint="Enter a subject..." />
<TextView hint="Enter a Message..."/>
<Button text="Submit" tap="onTap" />
</StackLayout>
</ScrollView>
</Page>
not: if I stop app with ctrl+c and y then restart my app with tns run android it runs successfully without any error.
I solved my problem with completely deleting platforms folder and rerun the app with tns run android.
Ok, I found the real error causing this, error happen whenever I change my app-root.xml'e defaultPage attribute to another page. I think this is an Issue with nativescript watch.
changing the app-root.xml's defaultPage attribute to another page while app is running is crashing the app.