I followed the instructions on the react-native-config package but Im getting the following error:
Native module RNCConfig Module tried to override RNCConfigModule. Check the getPackages() method in MainApplication.java , it might be that module is being created twice.
If I just install the package and don’t do the native steps, it doesn’t break like this but my Config on android is empty.
2
Answers
Through trial and error of commenting out different combinations of the native instructions and doing many gradlew cleans and reset cache (and ultimately having to delete my
android/.gradle
folder and clickSync Project with Gradle files
in Android Studio to remove a persistent ghostly remnant ofreact-native-config
after completely removing the package and code, I was encouraged by this thread: https://github.com/lugg/react-native-config/issues/741#issuecomment-1676199644I ended up only adding this to my
app/build.gradle
file and didn't add any of the other native Android parts as they listed in the instructions. This is how the top of it looks now:I'm using "react-native": "0.73.2", "react-native-config": "1.5.1",
You have to create .env file in root directory of your project.
and add these line in your
android/app/build.gradle
file.for more details
https://github.com/lugg/react-native-config/blob/master/Example/android/app/build.gradle