錯誤描述
- Execution failed for task ‘:app:mergeDebugResources’.
Could not resolve all files for configuration ‘:app:_internal_aapt2_binary’. - Could not download aapt2-osx.jar
- sun.security.provider.certpath.SunCertPathBuilderException
- Could not get resource ‘https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.5.0-5435860/aapt2-3.5.0-5435860-osx.jar’.
錯誤分析和解決方案
1. 無法合併資源。就是xml引用的原始組件,例如LinearLayout等組件引用錯誤,這種情況一般是Android Studio緩存混亂所致,就是你開多個不同gradle的項目緩存混亂了。
解決方法
Android studio點擊File → Invalidate Cache / Restart → Invalidate and Restart
等待重啓後解決
注意:點擊Invalidate and Restart之前只能有一個項目打開,不然重啓之後Gradle又會一起啓動然後衝突
2. 無法獲取資源。就是xml引用的原始組件無法獲取,這種情況一般是build.gradle沒有。
解決方法
打開build.gradle文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google() //查看這個Google是否存在且在第一個
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
google() //查看這個Google是否存在且在第一個
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
總結
通過以上兩個步驟大多數的錯誤都可以解決了,還沒有解決的話可以留言一起看看,別忘了點贊哦!