Please HELP!!
I’m working on an app in react-native that involves using a native Calendar module. I’m trying to register this module with react native and I keep getting this error.
This is how I’ve registered the module in MainApplication.java
:
@Override protected List<ReactPackage> getPackages() { List<ReactPackage> packages = new PackageList(this).getPackages(); packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider)); packages.add(new MyAppPackage()); return packages; }
This is the MyAppPackage.java file I’ve created using the tutorial here, https://reactnative.dev/docs/native-modules-android#register-the-module-android-specific.:
package com.chowtime; // replace your-app-name with your app’s name 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 MyAppPackage 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 CalendarModule(reactContext)); return modules; } }
Note: This app was previously created using the managed-workflow on expo and was ejected to the bare workflow. This is the directory for the relevant files:
Advertisement
Answer
Is this as simple as an import problem?
I noticed your MyAppPackage class is defined here:
package com.chowtime; // replace your-app-name with your app’s name
But your MainApplication error message seems indicate a sub-package, specifically “chowtime.chowtime”. Did you mean for both chowtimes?
com.chowtime.chowtime.MainApplication