unresolved reference BuildConfig

android, android-studio

Solution

Starting with android gradle plugin 8.0.0, you now have to explicitly tell gradle that you want to generate the `BuildConfig` file.

app/build.gradle

android {

    //...
    buildFeatures {
        compose = true
        buildConfig = true // <- set this to true
    }
}

Problem

When i'm try to rebuild my project i get the error below: ``` warning: flag is not supported by this version of the compiler: -Xallow-no-source-files warning: flag is not supported by this version of the compiler: -Xjava-source-roots=/Users/tyln/AndroidStudioProjects/PhoneBox/base/navigation/build/generated/source/buildConfig/dev/debug base/navigation/src/main/java/com/raqun/phonebox/navigation/IntentLoader.kt:7:9: error: unresolved reference: BuildConfig BuildConfig.PACKAGE_NAME, ^ > Task :base:navigation:compileDevDebugKotlin FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':base:navigation:compileDevDebugKotlin'. > Compilation error. See log for more details ``` When I check the class there're no unresolved references. I'm using Gradle Version 3.3.1 I almost tried everything such as `Invalidate Cache / Restart, Clean and Rebuild, Close and Reopen project, Reimport project, delete idea folder` etc but none of them worked. Thanks for your help.

Original source

Related problems