How To Set Canoverrideexistingmodule=true In React Native For Android Apps?
Solution 1:
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
Solution 2:
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.
Solution 3:
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:
@OverridepublicbooleancanOverrideExistingModule() {
returntrue;
}
And everything became correct.
Solution 4:
Go to the MainAplication file.
Remove duplicate package and remove duplicate package in getPackages() method
@Overrideprotected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
newMainReactPackage(),
newVectorIconsPackage()
);
}
Then after try this command in your terminal :
- cd android
- ./gradlew clean
Solution 5:
If the version of RN you're using is >= 0.60 then there is the possibility that auto-linking and your manual linking are doing the same thing twice. You have two options:
1- You can revert code changes in getPackages method
2- You can disable auto linking in react-native-config.js file.
Post a Comment for "How To Set Canoverrideexistingmodule=true In React Native For Android Apps?"