7

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) {

3 Answers 3

14

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

Sign up to request clarification or add additional context in comments.

Comments

4

Make sure you have same package name as in your MainApplication.java.

Example :

package com.appname;

For same in:

android/app/src/debug/java/com/appname/ReactNativeFlipper.java

and in

android/app/src/release/java/com/appname/ReactNativeFlipper.java

This solved my issue since I have changed my package name.

Comments

2

Not an ideal solution, but it worked for me:

I created file ReactNativeFlipper.java in android/app/src/main/java/com/myProject/ and put this code inside:

package com.myProject;
import android.content.Context;
import com.facebook.react.ReactInstanceManager;
public class ReactNativeFlipper {
  public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
    // Do nothing as we don't want to initialize Flipper on Release.
  }
}

Reference: https://github.com/facebook/react-native/issues/36060

Note: Don't forget to change myProject to your project's name

1 Comment

I saw we need put to release folder, not src folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.