ReactNative(Android)-找不到符号类ReactInstanceManager
我刚刚升级到 React Native 0.63.3
..... 我也升级了 Android studio4.1.1
和 gradle 插件到4.1.0
. 当我尝试构建时
出现错误cannot find symbol class ReactInstanceManager
。
错误在文件中MainApplication.java
......请参阅下面的代码。
出现错误是与行initializeFlipper(this,getReactNativeHost().getReactInstanceManager());
。似乎是说我提供com.facebook.react.ReactInstanceManager
....但是程序想要的是ReactInstanceManager
.
它说Get the current ReactInstanceManager instance, or create one.
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
* We use reflection here to pick up the class that initializes Flipper, since
* Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.xs.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
回答
在我将 RN 从 0.61.5 升级到 0.63.3 的过程中,我错过了一行代码。 import com.facebook.react.ReactInstanceManager;
MainApplication.java 中缺少
THE END
二维码