gpt4 book ai didi

android - react-native-maps 与 react-native 0.19.0 的集成问题

转载 作者:行者123 更新时间:2023-11-30 01:34:37 25 4
gpt4 key购买 nike

按照添加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);

}

我遇到了这个异常:

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)

这是 native 代码中异常的来源,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();

我试图注释掉 DialogModule 类中的断言并运行 react-native run-android 但它似乎没有反射(reflect)在我的模拟器中运行的编译代码中。

还尝试将 LifecycleState.RESUMED 设置为 LifecycleState.BEFORE_RESUME 但随后该应用仅加载空白屏幕并且开发菜单无法正常运行。

我错过了什么吗?

最佳答案

您的其他 Activity 是什么样的?我遇到了这个问题,但问题是我没有在我的 Activity 中实现 DefaultHardwareBackBtnHandler

下面是它们的实现方式:

@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();
}
}

关于android - react-native-maps 与 react-native 0.19.0 的集成问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35254232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com