【问题标题】:AAPT2 error - appcompat-v7 files not found in mergeDebugResourcesAAPT2 错误 - 在 mergeDebugResources 中找不到 appcompat-v7 文件
【发布时间】:2018-05-23 13:42:43
【问题描述】:

我有一个因错误而失败的 Hudson 构建作业

 Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

在日志中,有很多这样的行:

C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\3bbc697d357b69b5ea5f78a35f99a514\res\color\abc_hint_foreground_material_dark.xml: error: file not found.

我发现了一些关于此类 AAPT2 错误的问题,例如 thisthis,但它们似乎没有修复方法。

那么为什么构建失败了?

【问题讨论】:

    标签: android gradle android-gradle-plugin aapt2


    【解决方案1】:

    根据第一个链接问题,禁用 AAPT2 似乎是个坏主意,因为 AAPT 可能会在未来某个时候被删除。

    第二个链接问题至少提供了一个线索,接受的答案是该版本的 gradle 不处理 .gradle 缓存路径中的非 ASCII 字符。但在我们的例子中,缓存路径中没有任何非 ASCII 字符被记录。

    实际上,从日志来看,gradle 正在寻找C:\Windows\System32\config\systemprofile\.gradle 内部的缓存,只有管理员权限才能访问。不是我们想要缓存库的地方。

    This 答案以及 gradle 论坛上的 this post 是我找到解决方案的原因。短版本是,默认情况下,gradle 将下载的库缓存在用户区,并且似乎有一个 bug in Java 会错误地确定用户主目录。这会导致 gradle 缓存被放置在不应该放置的地方。

    为了解决这个问题,我们只需要设置 gradle 的用户主目录。 This blog post 有很多方法可以做到这一点。一种方法是创建一个 GRADLE_USER_HOME 环境变量,它的优点是适用于机器上的所有 gradle 构建。

    【讨论】:

    • 非常丰富的答案!感谢您发布您的发现!
    猜你喜欢
    • 2018-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-14
    相关资源
    最近更新 更多