[英]react-native-maps integration issue with react-native 0.19.0
As per instructions of adding react-native-maps , adding to MainActivity: 按照添加react-native-maps的说明 ,添加到MainActivity中:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new AirPackage()) // <---- and This!
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "MelBike", null);
setContentView(mReactRootView);
}
I encountered this exception: 我遇到此异常:
java.lang.AssertionError: Attached DialogModule to host with pending alert but no FragmentManager (not attached to an Activity).
at com.facebook.infer.annotation.Assertions.assertNotNull(Assertions.java:28)
at com.facebook.react.modules.dialog.DialogModule.onHostResume(DialogModule.java:199)
at com.facebook.react.bridge.ReactContext.onResume(ReactContext.java:140)
at com.facebook.react.ReactInstanceManagerImpl.moveReactContextToCurrentLifecycleState(ReactInstanceManagerImpl.java:761)
at com.facebook.react.ReactInstanceManagerImpl.setupReactContext(ReactInstanceManagerImpl.java:599)
at com.facebook.react.ReactInstanceManagerImpl.access$700(ReactInstanceManagerImpl.java:84)
at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.onPostExecute(ReactInstanceManagerImpl.java:187)
at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.onPostExecute(ReactInstanceManagerImpl.java:162)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
This is the source of the exception in react native code, DialogModule class: 这是react本机代码DialogModule类中的异常的来源:
public void onHostResume() {
mIsInForeground = true;
// Check if a dialog has been created while the host was paused, so that we can show it now.
FragmentManagerHelper fragmentManagerHelper = getFragmentManagerHelper();
Assertions.assertNotNull(
fragmentManagerHelper,
"Attached DialogModule to host with pending alert but no FragmentManager " +
"(not attached to an Activity).");
fragmentManagerHelper.showPendingAlert();
I have tried to comment out the assertion in DialogModule class and run react-native run-android but it seems it was not reflected in compiled code that ran in my emulator. 我试图注释掉DialogModule类中的断言并运行react-native run-android,但似乎未反映在仿真器中运行的已编译代码中。
Also tried to set the LifecycleState.RESUMED to LifecycleState.BEFORE_RESUME but then the app only loads blank screen and Dev menu wasn't functioning properly. 也试过设置LifecycleState.RESUMED到LifecycleState.BEFORE_RESUME但随后的应用程序只加载空白的屏幕和菜单开发是不正常。
Am I missing something? 我想念什么吗?
What does the rest of your activity look like? 其余活动看起来如何? I ran into this but the problem was that I was not implementing DefaultHardwareBackBtnHandler in my activity.
我遇到了这个问题,但问题是我没有在活动中实现DefaultHardwareBackBtnHandler 。
Here is how they are implemented: 这是它们的实现方式:
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onPause();
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onResume( this, this );
}
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.