react-native-config not working in release builds
Asked Answered
R

2

7

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.

Rinse answered 22/6, 2022 at 3:18 Comment(0)
C
19

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.

Cat answered 22/6, 2022 at 3:20 Comment(4)
this solved my issue, please try this outRinse
just saved my day tooValerievalerio
I love you so muchInstancy
Searching since last 2 days and this worksOestradiol
E
0

Solution 1: Make def enableProguardInReleaseBuilds = false in android/app/build.gradle file.

Solution 2: Make def enableProguardInReleaseBuilds = true in android/app/build.gradle file and then *add -keep class com.mypackage.BuildConfig { ; } in the file path android/app/proguard-rules.pro

Replace com.mypackage with your project’s package name.

Engud answered 13/10, 2023 at 11:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.