Skip to content

MyApplication class cannot be cast to com.facebook.react.ReactApplication #2801

@rishabh876

Description

@rishabh876

I am currently working on upgrading RN version of my project from 0.61.5 to 0.63.4. In parallel I am also upgrading reanimated v1.13.2 to v2.3.1.
Now the problem is that I don't have ReactApplication. I build ReactInstanceManager in my activity.

Description

After upgrading I get the following error on app launch

com.example.MyApplication class cannot be cast to com.facebook.react.ReactApplication
createUiManager (ReanimatedPackage.java : 70)

Expected behavior

No crash on app start.

Actual behavior & steps to reproduce

Steps: Upgrading from v1 to v2 without any ReactApplication.

Snack or minimal code example

// onCreate of my activity
        mReactRootView = new ReactRootView(this);
        mReactInstanceManager = ReactInstanceManager.builder()
                                                    .setApplication(getApplication())
                                                    .setCurrentActivity(this)
                                                    .setBundleAssetName("index.android.bundle")
                                                    .setJSMainModulePath("index")
                                                    .setJSIModulesPackage((reactApplicationContext, jsContext) -> {
                                                        return new ReanimatedJSIModulePackage().getJSIModules(reactApplicationContext, jsContext);
                                                    })
                                                    .addPackage(new LinearGradientPackage())
                                                    .addPackage(new ImagePickerPackage())
                                                    .addPackage(new ImageResizerPackage())
                                                    .addPackage(new SvgPackage())
                                                    .addPackage(new FastImageViewPackage())
                                                    .addPackage(new NetInfoPackage())
                                                    .addPackage(new LottiePackage())
                                                    .addPackage(new RNPermissionsPackage())
                                                    .addPackage(new RNGestureHandlerPackage())
                                                    .addPackage(new BackgroundTimerPackage())
                                                    .addPackage(new RNCWebViewPackage())
                                                    .addPackage(new ReanimatedPackage())
                                                    .setUseDeveloperSupport(BuildConfig.DEBUG)
                                                    .setInitialLifecycleState(LifecycleState.RESUMED)
                                                    .build();

        Bundle initialProps = getInitProps();
        mReactRootView.startReactApplication(mReactInstanceManager, "example", initialProps);
        setContentView(mReactRootView);

Package versions

  • React Native: 0.63.4
  • React Native Reanimated: 2.3.1
  • NodeJS: v14.5.0
  • Xcode:
  • Java & Gradle: 3.5.3

Affected platforms

  • Android
  • iOS
  • Web

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions