How to set canOverrideExistingModule=true in React Native for Android Apps?
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.
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 :
- the import package :
import com.airbnb.android.react.maps.MapsPackage
- the call to the constructor of the module :
new MapsPackage()
in functiongetPackages
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.