首页 > 解决方案 > 无法解析配置“:app:_internal_aapt2_binary”的所有文件

问题描述

我在构建应用程序时收到此错误消息

FAILURE:构建失败并出现异常。

任务 ':app:mergeDebugResources' 执行失败。
无法解析配置“:app:_internal_aapt2_binary”的所有文件。
org.gradle.api.GradleException:无法读取路径“C:\Users\Abdullah.gradle\caches\transforms-2\files-2.1\322973851a21411e089a9e85629c04f5\aapt2-3.4.0-5326820-windows”。

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'

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

allprojects {
    String osName = System.getProperty("os.name").toLowerCase();
    if (osName.contains("windows")) {
        buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    }
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

标签: android

解决方案


看起来您正在使用 jCenter() 存储库。根据官方 google 文档,您将需要手动更改项目依赖项的位置。

脚步:

  1. 删除 buildScript build.gradle-> repositories 内(文件项目)中的 jCenter() 并添加mavenCentral()

构建脚本

    repositories {
        google()
        mavenCentral() // New line
        jcenter() //remove that line
    }
  1. 你应该在allprojects

     repositories {
         google()
         mavenCentral() // New line
         jcenter() //remove that line
        // NOTE: Keep any other entries you may have had here
     }
    
  2. 同步项目

您可以在官方文档中找到有关此处的更多信息


推荐阅读