Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

BuildConfig is red or missing after a plugin upgrade

ErrorCannot resolve symbol 'BuildConfig'

Short answer

Since Android Gradle plugin 8.0 the BuildConfig class is no longer generated unless a module asks for it. Turn on buildFeatures.buildConfig in the module that reads BuildConfig, or restore the old default for every module with the android.defaults.buildfeatures.buildconfig property, then sync.

  • Applies to Android Gradle plugin 8.x and 9.x, Gradle 8.x and 9.x, Android Studio current stable
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check whether the module that uses BuildConfig turns generation on. Search every build file for the flag.

    grep -rn "buildConfig" --include=build.gradle --include=build.gradle.kts --include=gradle.properties .
  2. 2Match what you see, then jump to its fix

    1. 1The project built before upgrading to AGP 8 or newer, and the error covers only the BuildConfig classBuildConfig generation is off in this moduleFix
    2. 2The app compiles, while a library or feature module still reports the symbol as unresolvedOnly one module was fixed, but several modules read their own BuildConfigFix

What does the error look like?

  • Cannot resolve symbol 'BuildConfig'

Cause 1 of 2

BuildConfig generation is off in this module

1Check

AGP 8.0 changed the default of buildConfig from true to false, and the DSL reference gives the default as false. A module that never sets it gets no class.

grep -n "buildFeatures" -A3 app/build.gradle app/build.gradle.kts

2Fix

Enable it in the module that needs the class. This also generates fields you declare with buildConfigField.

// build.gradle.kts
android {
    buildFeatures {
        buildConfig = true
    }
}

3Verify

Sync, then build the module and look for the class in the module's build output.

./gradlew :app:assembleDebug
find app/build -name BuildConfig.java

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

Only one module was fixed, but several modules read their own BuildConfig

1Check

The release notes say to specify the option in the projects where you need it, so the flag is set per module, not once for the build.

grep -rLn "buildConfig = true" --include=build.gradle.kts .

2Fix

Add buildFeatures { buildConfig = true } to every module that reads BuildConfig. For an older project that relied on the old default everywhere, set the global property in gradle.properties at the root.

# gradle.properties
android.defaults.buildfeatures.buildconfig=true

3Verify

Sync and build the whole project.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • After every AGP upgrade, read the release notes list of changed defaults before you debug unresolved symbols.
  • Prefer enabling buildConfig only in the modules that need it; the default was changed to keep builds faster.
  • Keep the flag in each module's build file, not in a copied snippet that nobody remembers.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.