android - 如何修复 android Studio 4.1.1 中的 aapt2 错误?

标签 android maven android-studio kotlin android-gradle-plugin

几天前我删除了整个 gradle 文件并再次手动安装
介绍了它到 android studio 4.1.1 的路径并创建了一个项目来测试
幸运的是 gradle 工作正常,但是当我尝试在模拟器上运行应用程序时,出现了一个红色的该死错误,让我无法睡 3 天

Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
   > Could not find aapt2-4.1.1-6503028-linux.jar (com.android.tools.build:aapt2:4.1.1-6503028).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.1.1-6503028/aapt2-4.1.1-6503028-linux.jar

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html


我阅读了文档,我猜这已经过时或者无法解决我的问题
因为我声明了存储库,但没有任何改变。
我找到的每个解决方案都属于 2 或 3 年前,而且大多数人都说同样的话
添加 google()给您的repositoriesbuild.gradle他们是对的
这应该可以解决问题,但在 3 年前。
现在默认 android studio 有 google()repositories我仍然在屏幕上看到该死的红色错误
in error 显然指向丢失了一个名为 aapt2-4.1.1-6503028-linux.jar 的文件。感谢谷歌,它给了我下载链接
我下载了文件,但我不知道放在哪里。
正如错误所说,Could not resolve all files for configuration ':app:_internal_aapt2_binary'.所以有人知道这个文件的路径或者它是什么?!
让一个老菜鸟程序员快乐;(

最佳答案

嗨,对不起,迟到的答案,可能会对其他人有用
将 Maven 添加到您的项目 build.gradle 应用程序中,它将解决

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

关于android - 如何修复 android Studio 4.1.1 中的 aapt2 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64946895/

相关文章:

背景为黑色时,Android PorterDuff.Mode.CLEAR 无法正常工作

java - Maven 外部依赖

java - Maven - 合并导入包的自动和手动列表

android - Unresolved reference @HiltAndroidApp 或 Android 中的任何其他 Hilt 注释

android - 如何让多个 Intent 过滤器在同一个任务中启动一个 Activity

android - LIBGDX 游戏配置与 google Play 游戏服务错误

java - Spring MVC - 意外异常解析来自 ServletContext 资源的 XML 文档 [/WEB-INF/mvc-dispatcher-servlet.xml];

Android Studio, "local.properties"文件的值神秘不正确?

android - "Compatible side by side NDK version was not found. Default is 20.0.5594570."是什么意思?

java - 空异常。数据库已锁定