1.问题:Gradle下载失败
解决方案:修改gradle-wrapper.properties中的distributionUrl下载地址,修改成国内能访问的网址,如下:
将distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip修改为distributionUrl=https\://downloads.gradle-dn.com/distributions/gradle-7.1-all.zip
gradle所有版本下载网址:https://gradle.org/releases/】
在androidstudio的终端里使用gradlew命令进行下载更新
更新完成:
2.问题:org.gradle.internal.execution.WorkValidationException: A problem was found with the configuration of task ':app:checkDebugManifest' (type 'CheckManifest').
解决方案:app或module的build.gradle 中使用了文件路径的引用,需要注解
gradle相关文档:https://docs.gradle.org/current/userguide/validation_problems.html#incorrect_use_of_input_annotation
sourceSets{
main{
if(isModule.toBoolean()){
manifest.srcFile getManifestPath(true)
}
else{
manifest.srcFile getManifestPath(false)
}
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
@InputFile
static def getManifestPath(boolean flag){
if (flag) {
return 'src/main/buildApp/AndroidManifest.xml'
}else{
return 'src/main/buildModule/AndroidManifest.xml'
}
}