android - 无法解析配置 ':app:_internal_aapt2_binary' 的所有文件

标签 android

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

FAILURE: Build failed with an exception.


  • 出了什么问题:

  • Execution failed for task ':app:mergeDebugResources'.
    Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
    org.gradle.api.GradleException: Could not read path '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
    }
    

    最佳答案

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

  • 删除 build.gradle 中的 jCenter() (file project) 在 buildScript -> repositories 中添加 mavenCentral()

  • 构建脚本
        repositories {
            google()
            mavenCentral() // New line
            jcenter() //remove that line
        }
    
  • 你应该在 allprojects 中做同样的事情
     repositories {
         google()
         mavenCentral() // New line
         jcenter() //remove that line
        // NOTE: Keep any other entries you may have had here
     }
    
  • 同步项目

  • 您可以在 official documentation 上找到更多信息。

    关于android - 无法解析配置 ':app:_internal_aapt2_binary' 的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55790995/

    相关文章:

    android - 如何在表面 View 上自定义相机的预览?

    java - 是否可以将同一个对象保存到两个不同的表房间?

    android - Android 相当于 iPhone 上的表格 View 是什么?

    android - 带有 Kotlin 协程的房间观察数据库变化

    java - 在使用 java 的 ARCore 中,如何在我的世界中绘制 3D 三角形/线

    android - 蓝牙配对 - 如何显示简单的取消/配对对话框?

    android - react native : TouchableOpacity onPress problems inside a ScrollView

    android - 在我现有的项目 (eclipse) 中导入 CardView 和 RecyclerView (Android 5.0)

    android - 构建新的 APK 版本时,新的更改不适用

    java - 使位图的触摸区域变为透明