csath / csath/react-native-config-reader

Enabling ProGuard results in "Could not find BuildConfig class" error when attempting to assembleRelease

Open
#21 6 comments 0 reactions 0 assignees View on GitHub
bug good first issue platform: android question
Dominant language
Objective-C
Stars
47
Forks
17
PR merge metrics
No merged PRs in 30d

Description

**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 {
constructor(props: any) {
super(props)

console.log('Config', JSON.stringify(Config))
}
}
```

`Config` returns `null`.

Any suggestions?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.