react-native-config-reader
react-native-config-reader copied to clipboard
Enabling ProGuard results in "Could not find BuildConfig class" error when attempting to assembleRelease
React Native: 61
Android: AndroidX
There seems to be an issue with assembling for release when using ProGuard:
android() {
...
buildTypes {
debug {
buildConfigField "String", "FOO", "\"bar\""
}
release {
buildConfigField "String", "FOO", "\"baz\""
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
...
}
In short, attempting to build via ./gradlew assembleRelease -x bundleReleaseJsAndAssets builds the project just fine, but it results in RN Config Reader throwing the following error:
ReactNative: RNConfigReader: Could not find BuildConfig class
The app assembles and works just fine using assembleDebug. All of the build variant BuildConfig files are properly automatically generated with the correct values.
import Config from 'react-native-config-reader'
export default class Root extends React.Component<void, void> {
constructor(props: any) {
super(props)
console.log('Config', JSON.stringify(Config))
}
}
Config returns null.
Any suggestions?
try cd android && ./gradlew app:assembleRelease
Seems it renames the BuildConfig Java class in ProGuard minification process.
@todesignandconquer Can you try adding this line to your android/app/proguard-rules.pro
-keep class com.yourNewPackage.BuildConfig { *; }
Please note that com.yourNewPackage should be replaced with your package name.
This should hopefully resolve your issue.
I am having the same issue I upgraded from RN 0.59.10 to RN 0.61.5 and now RNConfigReader is null works on iOS fine just an Android issue. I tried the above solution but it didn't work. Any other help with this would be much appreciated.
The version of the library I am using is: "react-native-config-reader": "^4.1.1"
Update: The issue is definitely with this library as I installed another and everything works fine now.
Update: The issue is definitely with this library as I installed another and everything works fine now.
@AdamLee321 which one did you install that fixes this?
Hey, everyone. I wanted to introduce myself as a new maintainer for this project. More information about circumstances is available in my closing comment on #41, so please have a look there for some important information.
That said, I'm just checking in on some existing issues and seeing if they're still relevant, as well as exploring how to proceed.