Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BuildConfig cannot resolve solution

Gradle buildConfigField BuildConfig cannot resolve symbol

In latest android studio with gradle version 8.0.0 and above developer face this issu. When they try to import BuildConfig class with own package name but it's can't working. From the import can not found own packagename. So, developer confused why it's not showing and take to much time for solving this issue.

But this is new feature provided by latest android studio with gradle version 8.0.0 and above. So, you just place simple code as showing below in build.gradle file.

android {
  buildFeatures {
        buildConfig = true
    }
 }

Why use buildFeatures?

A list of build features that can be disabled or enabled in an Android Application project. A list of build features that can be disabled or enabled in an Android Dynamic Feature project.

buildConfig

abstract var buildConfig: Boolean?

Flag to enable/disable generation of the BuildConfig class.

Setting the value to null resets to the default value. Default value is true.

You can override the default for this for all projects in your build by adding the line android.defaults.buildfeatures.buildconfig=true in the gradle.properties file at the root project of your build.

like image 890
Jasani Chirag Avatar asked Nov 29 '25 22:11

Jasani Chirag


1 Answers

Remove the = (equals symbol), as that is what the error is complaining about

buildFeatures {
    buildConfig true
} 

for a example of complex app/build.gradle, check out https://github.com/TeamNewPipe/NewPipe/blob/master/app/build.gradle

like image 129
petey Avatar answered Dec 02 '25 14:12

petey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!