私のネイティブスクリプトアプリケーションは、最初の実行ではエラーなしで正常に実行されますが、ファイルを変更せずに保存したり、小さな変更を加えたりすると、以下の情報でアプリがクラッシュします。
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)
app-root.xml ファイルの内容は次のとおりです。
<Frame defaultPage="views/contact-us/contact-us">
</Frame>
ファイル構造は次のとおりです。
├───app
│ ├───App_Resources
│ │ ├───Android
│ │ └───iOS
│ └───views
│ ├───about
│ ├───contact-us
│ └───home
├───hooks
...
contact-us.xml ファイルの内容も次のとおりです。
<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>
そうではありません: ctrl + cとyでアプリを停止し、 tns run androidでアプリを再起動すると、エラーなしで正常に実行されます。