Skip to content

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

Description

@todesignandconquer

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersplatform: androidAffects AndroidquestionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions