在Android build,gradle下面,添加右边红框的代码:
subprojects {
afterEvaluate { project ->
if (project.plugins.hasPlugin("com.android.application") ||
project.plugins.hasPlugin("com.android.library")) {
project.android {
compileSdkVersion 34
buildToolsVersion "34.0.0"
}
}
}
}
注意要加在下面这段代码的上面一行:
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
否则会报:Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.