Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native (Android) - cannot find symbol class ReactInstanceManager

I just upgraded to React Native 0.63.3.....I also upgraded Android studio to 4.1.1 and gradle plugin to 4.1.0.
Im getting the error cannot find symbol class ReactInstanceManager when I try to build.

The error is in file MainApplication.java.....see code below.
Appears the error is with the line initializeFlipper(this,getReactNativeHost().getReactInstanceManager());. It seems to be saying that Im providing com.facebook.react.ReactInstanceManager....but what the program wants is ReactInstanceManager.
It says 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) {
like image 535
james murphy Avatar asked Jan 21 '21 23:01

james murphy


Video Answer


1 Answers

I missed a single line of code during my upgrgade of RN from 0.61.5 to 0.63.3.
import com.facebook.react.ReactInstanceManager; was missing from MainApplication.java

like image 65
james murphy Avatar answered Oct 23 '22 10:10

james murphy