I built an android app using React Native, it got built successfully but when I run the app in my Android Virtual Device it shows up a full red screen with the following error:
I have not done native app development ever before neither do I have any knowledge of Java so I have no idea what this error means and how to fix this.
However we recommend that you use ReactContextBaseJavaModule, as shown above. ReactContextBaseJavaModule gives access to the ReactApplicationContext (RAC), which is useful for Native Modules that need to hook into activity lifecycle methods.
For Android, Java native modules are written as classes that extend ReactContextBaseJavaModule and implement the functionality required by JavaScript. It is worth noting that technically Java classes only need to extend the BaseJavaModule class or implement the NativeModule interface to be considered a Native Module by React Native.
To register the CalendarModule package, you must add MyAppPackage to the list of packages returned in ReactNativeHost's getPackages () method. Open up your MainApplication.java or MainApplication.kt file, which can be found in the following path: android/app/src/main/java/com/your-app-name/.
But question is where to override? first of all, you can't override inside MainActivity.java or MainApplication.java file. You should override it in the class inside some node_modules project folder and that class will be extending from ReactContextBaseJavaModule class.
The name of the package associated to this error is not AirMapModule
but MapsPackage
from com.airbnb.android.react.maps
.
In your MainApplication.java
in directory : android/app/src/main/java/../../
remove any duplicate entry of :
import com.airbnb.android.react.maps.MapsPackage
new MapsPackage()
in function getPackages
Go to file "MainApplication.java" (under .\android\app\src\main\java\com\projectName\
)
Make sure that under getPackages()
function you don't have duplicate lines (in my case I had "new MapsPackage()" twice).
Fix duplicate imports as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With