萌萌の初音
萌萌の初音
发布于 2024-07-18 / 176 阅读
0

使用AGP8项目提示BuildConfig找不到

将AGP升级到8后,代码提示BuildConfig.Debug找不到,通过以下配置即可解决;
在项目的build.gradle中添加以下内容:

android {
    // ...你的其他配置
    buildFeatures {
        buildConfig true
        // ...你的其他配置
    }
}

在项目根目录中的gradle.properties添加以下配置

android.defaults.buildfeatures.buildconfig=true

通过以上两个配置再进行rebuild porject,错误提示就消失了