Open aledustet opened 4 years ago
Same issue here on RN => 0.0.63.
Check if proguard is enabled, if so you have to add this in android/app/proguard-rules.pro
: replace mypackage
with equivalent package name.
-keep class com.mypackage.BuildConfig { *; }
@haseebeqx we have proguard
enabled https://github.com/Path-Check/covid-safe-paths/blob/f8195a3a91301d182e0df7ab65f1b59560a75a36/android/app/proguard-rules.pro#L13 on the default flavor of the app all environment variables are available, is just when we change the bundle identifier that the Config
is undefined.
@aledustet Why you need to bundle identifier?. If it is for rebranding I think you can add a README instruction for user to update this config also.
@haseebeqx the way the product is set up, we need to handle two different applications for different flows. Each one is a different product. We are using the different configuration files for different bundle identifiers using schemes on the iOS side. This behavior allows us to have one 'environment' for the iOS native code and the javascript code. The same should be true for the android native code. The equivalent to schemes on android is the product flavors, and those are configured in the same way. Hope this answers your question
In our case, it doesn't work when we use applicationIdSuffix
in app build.graddle...
I had the same issue when setting up flavors with an applicationIdSuffix, and the solution was to specify a resValue like this comment mentions: https://github.com/luggit/react-native-config/issues/223#issuecomment-441662643
I'm getting this error: Could not get unknown property 'dev' for DefaultConfig_Decorated
when I moved apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
on the top of the file, I think it's because it's messing with my build config flavors:
flavorDimensions "version"
productFlavors {
dev {
applicationIdSuffix ".dev"
}
staging {
applicationIdSuffix ".staging"
}
production {}
}
Can anyone help?
Check if proguard is enabled, if so you have to add this in
android/app/proguard-rules.pro
: replacemypackage
with equivalent package name.-keep class com.mypackage.BuildConfig { *; }
Thanks, It worked with my jitsi-meeting project.
@aledustet have you found a resolution to this? Facing the same issue as you
We are using RN => 0.61.5, and the latest version of
react-native-config
This is an open-source project, here is the repo. There is a split for two flavors of the applications, one BT and one GPS, on the iOS version, the pre-build scripts copying the right env file on the right Scheme works and each version of the app loads the correct set of
env
variables. When the Android version builds for the GPS flavor the environment variables are made available on thereact-native
side and everything works. Is worth noticing that the default and original configuration was made for the GPS side, using the originalappId
. When theBT
flavor builds, if we spoof inside thedotenv.gradle
thebuildConfig
is picked up and the right env file is found, we can see it in the build output and if we print theenv
that is being used inside that file it has all the right values. However, as soon as the app builds ourConfig
imported fromreact-native-config
is empty.Things we have tried:
proguard-rules
buildConfig
alone and only using one .env file