异常提示:
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;}}