How to set canOverrideExistingModule=true in React Native for Android Apps?

UtkarshPramodGupta picture UtkarshPramodGupta · Jan 25, 2017 · Viewed 37.5k times · Source

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:

enter image description here

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.

Answer

efx picture efx · Mar 19, 2017

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 function getPackages