androidreact-nativereact-native-native-module

class must either be declared abstract or implement abstract method called createJSModules in ReactPackage


I am following Native Module documentation for android: https://facebook.github.io/react-native/docs/native-modules-android.html#docsNav

My package currently looks like this

package com.myCompany.asqgooglesignin;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ASQGoogleSignInPackage implements ReactPackage {

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return Collections.emptyList();
    }

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        List<NativeModule> modules = new ArrayList<>();
        modules.add(new ASQGoogleSignIn(reactContext));
        return modules;
    }
}

and I am getting following error

class must either be declared abstract or implement abstract method called createJSModules in ReactPackage

Documentation does not mention anything about createJSModules should I include it and what is correct way to do so?

This is using latest dependency

implementation 'com.facebook.react:react-native:+'

Solution

  • I think this method was removed in React Native version 0.47. Are you sure your React Native version is update to date in npm? You can can check your version by running react-native -v from your project directory. Any version above this shouldn't require that method to be implemented. If you don't want to change your version, try simply implementing the method with return Collections.emptyList();.