javaandroidreact-nativereact-native-gesture-handler

Issue with RNGestureHandlerEnabledRootView not being supported : java.lang.UnsupportedOperationException


I am getting an issue with react-native-gesture-handler library. I have upgraded to the latest version "^2.9.0". I am not able to run my build as it crashes on opening the app giving me a summary:- java.lang.UnsupportedOperationException: Your application is configured to use RNGestureHandlerEnabledRootView which is no longer supported.

I have read the documentation for migrating off RNGHEnabledRootView but that too doesn't solve the problem. I have changed MainActivity.java file by editing :

import com.swmansion.gesturehandler.RNGestureHandlerPackage;

But getting issue with :

@Override
    protected ReactActivityDelegate createReactActivityDelegate() {
        return new ReactActivityDelegateWrapper(this, new ReactActivityDelegate(this, getMainComponentName()) {
            @Override
            protected ReactRootView createRootView() {
                return new RNGestureHandlerEnabledRootView(MainActivity.this);
            }
        });
    }

error: cannot find symbol return new RNGestureHandlerEnabledRootView(MainActivity.this); ^ symbol: class RNGestureHandlerEnabledRootView

Execution failed for task ':app:compileDebugJavaWithJavac'.


Solution

  • According to this page in the documentation, you have to remove RNGestureHandlerEnabledRootView and use the below code in your MainActivity

    Java:

    @Override
    protected ReactActivityDelegate createReactActivityDelegate() {
        return new MainActivityDelegate(this, getMainComponentName());
    }
    

    Kotlin:

    override fun createReactActivityDelegate(): ReactActivityDelegate? {
        return MainActivityDelegate(this, getMainComponentName())
    }