Android Could not resolve all files for configuration ':app:_internal_aapt2_binary'.错误解决方式大全

错误描述

  1. Execution failed for task ‘:app:mergeDebugResources’.
    Could not resolve all files for configuration ‘:app:_internal_aapt2_binary’.
  2. Could not download aapt2-osx.jar
  3. sun.security.provider.certpath.SunCertPathBuilderException
  4. 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
}

总结

通过以上两个步骤大多数的错误都可以解决了,还没有解决的话可以留言一起看看,别忘了点赞哦!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章