react-native-config not working in release builds

I was using react-native-config to support multiple flavours for multiple release builds. I’ve created multiple .env files also and all the debug builds are able to access it and getting the configs. There is no problem in the debug builds but when it comes to release builds they are not getting the configs from the env file. I tried to toast the config and it shows empty string.

>Solution :

This might be mostly problem with Proguard.

When Proguard is enabled (which it is by default for Android release builds), it can rename the BuildConfig Java class in the minification process and prevent React Native Config from referencing it. To avoid this, add an exception to android/app/

-keep class com.mypackage.BuildConfig { *; }

mypackage should match the package value in your app/src/main/AndroidManifest.xml file.

Leave a Reply