700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Android原生集成RN的坑:Trying to add a root view with an explicit id already set.

Android原生集成RN的坑:Trying to add a root view with an explicit id already set.

时间:2024-05-20 08:22:38

相关推荐

Android原生集成RN的坑:Trying to add a root view with an explicit id already set.

异常提示:

com.facebook.react.uimanager.IllegalViewOperationException: Trying to add a root view with an explicit id already set. React Native uses the id field to track react tags and will overwrite this field. If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView.at com.facebook.react.uimanager.NativeViewHierarchyManager.addRootViewGroup(NativeViewHierarchyManager.java:510)at com.facebook.react.uimanager.NativeViewHierarchyManager.addRootView(NativeViewHierarchyManager.java:502)at com.facebook.react.uimanager.UIViewOperationQueue.addRootView(UIViewOperationQueue.java:605)at com.facebook.react.uimanager.UIImplementation.registerRootView(UIImplementation.java:211)at com.facebook.react.uimanager.UIManagerModule.addRootView(UIManagerModule.java:302)at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1021)at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:978)at com.facebook.react.ReactInstanceManager.access$1300(ReactInstanceManager.java:113)at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:941)at android.os.Handler.handleCallback(Handler.java:790)at android.os.Handler.dispatchMessage(Handler.java:99)at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)at android.os.Looper.loop(Looper.java:164)at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)at java.lang.Thread.run(Thread.java:764)

解决办法:

@Overrideprotected void onDestroy() {super.onDestroy();if (mReactInstanceManager != null) {mReactInstanceManager.destroy();}if(mReactRootView!=null) {mReactRootView.unmountReactApplication();mReactRootView = null;}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。