将NativeScript更新到5.0.0后出现错误

时间:2018-11-20 07:42:05

标签: nativescript updates nativescript-angular

我是NativeScript的新手。将NativeScript更新为5.0.0之后,当我创建默认项目并使用tns run android命令运行时,出现以下错误:

 System.err: com.tns.NativeScriptException:
System.err: Calling js method onViewAttachedToWindow failed
System.err: TypeError: this._context.getSupportFragmentManager is not a function
System.err: File: "file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/core/view/view.js, line: 190, column: 46
System.err: StackTrace:
System.err:     Frame: function:'View._getRootFragmentManager', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 190, column: 47
System.err:     Frame: function:'View._getFragmentManager', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 215, column: 32
System.err:     Frame: function:'Frame._processNextNavigationEntry', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 134, column: 28
System.err:     Frame: function:'Frame._onAttachedToWindow', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 118, column: 14
System.err:     Frame: function:'AttachListener.onViewAttachedToWindow', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 35, column: 27
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_29_36_AttachListener.onViewAttachedToWindow(Object_frame_29_36_AttachListener.java:17)
System.err:     at android.view.View.dispatchAttachedToWindow(View.java:13554)
System.err:     at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2690)
System.err:     at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2697)
System.err:     at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2697)
System.err:     at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2697)
System.err:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1322)
System.err:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
System.err:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
System.err:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
System.err:     at android.view.Choreographer.doCallbacks(Choreographer.java:580)
System.err:     at android.view.Choreographer.doFrame(Choreographer.java:550)
System.err:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
System.err:     at android.os.Handler.handleCallback(Handler.java:739)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
System.err:     at android.os.Looper.loop(Looper.java:135)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:5343)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at java.lang.reflect.Method.invoke(Method.java:372)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
ActivityManager: Process org.nativescript.DemoApp (pid 22172) has died

请帮助我回答。由于我已经更新了NativeScript Version,因此我面临着这个问题。

3 个答案:

答案 0 :(得分:3)

你有类似的东西

class MainActivity extends android.app.Activity {

我将本机版本5的活动更新为AppCompatActivity

class Activity extends android.support.v7.app.AppCompatActivity {

错误消失了。

但是如果您有startActivityForResult,也许您会得到其他new errors

答案 1 :(得分:0)

很可能您仅升级了NativeScript CLI,而不升级了项目的依赖项和运行时。请遵循this documentation section中的详细升级说明,并通过更新运行时(“ tns-android”和/或“ tns-ios”),模块(“ tns-core-modules”)来确保已迁移了整个项目')和所有相关的插件/依赖项。

答案 2 :(得分:0)

我已经解决了这个问题。实际上,我对AndroidStudio有疑问。通过在ClearCache中进行AndroidStudio,我的问题得到解决。 AndroidStudio被占用在磁盘中可能是空间问题,因此我的NativeScript应用程序没有足够的空间。