Android Could not resolve all files for configuration ‘:app:_internal_aapt2_binary‘

柳鸿博
2023-12-01

前言

在运行一个身份识别demo的时候
编译过程报错Android Could not resolve all files for configuration ':app:_internal_aapt2_binary'

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
> Could not find com.android.tools.build:aapt2:3.5.3-5435860.

解决方法

需要在build.gradle配置中添加
google() 和 jcenter()
具体参考下面的代码配置
配置好sync again 即可!

buildscript {
    repositories {

        google()
        jcenter()

        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'https://maven.aliyun.com/repository/public/' }
        maven { url 'https://maven.aliyun.com/repository/google/' }
        maven { url 'https://maven.aliyun.com/repository/jcenter/' }
        maven { url 'https://maven.aliyun.com/repository/central/' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {

        google()
        jcenter()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }

    }
}
 类似资料: