Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 653
Amal Mohan N Avatar asked Jun 05 '26 14:06

Amal Mohan N


1 Answers

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/proguard-rules.pro:

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

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

like image 170
AMAL MOHAN N Avatar answered Jun 08 '26 04:06

AMAL MOHAN N



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!