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 err
Solution
Goto android/app/src/main/java/YOURPACKAGE/MainApplication.java
Find method getPackages();
Remove this packages.add(new MapsPackage());
Chill Pill! :)
Open the MainApplication.java
file by this address: android/app/src/main/java/com/projectName/MainApplication.java
and add the following code to MainApplication.java
file:
@Override
public boolean canOverrideExistingModule() {
return true;
}
And everything became correct.
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.
You can try check in file MainApplication.java
in directory : android\app\src\main\java
is have any duplicate package AirMapModule exist or not, and delete 1 if have.
Go to the MainAplication file.
Remove duplicate package and remove duplicate package in getPackages()
method
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage()
);
}
Then after try this command in your terminal :
Add only the modules which are not autolinked at here,
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// example: packages.add(new MyReactNativePackage());
return packages;
}
If the module is autolinked and added the module here, you will get this error.