几天前我删除了整个 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()
给您的repositories
在 build.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/