【问题标题】:Failed linking references - style attribute '@android:attr/textColor' not found in appcompat链接引用失败 - 在 appcompat 中找不到样式属性“@android:attr/textColor”
【发布时间】:2018-06-06 06:53:09
【问题描述】:

我正在尝试从我们的项目中删除即将删除的选项android.enableAapt2=false。这很痛苦,但我希望我能到达那里。

现在我被 BuildException: Failed to process resources, see aapt output above for details 困住了。

问题似乎是这样的:

error: style attribute '@android:attr/textColor' not found.
Message{kind=ERROR, text=error: style attribute '@android:attr/textColor' not found., 
sources=[/Users/<username>/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/4215c9c9bb2efc5bb086ff343ac44128/res/values/values.xml], 
original message=, tool name=Optional.of(AAPT)}

我找到了以下问题和答案,但我相信当它不在我们自己的项目中时会有所不同:Cannot complete Gradle Build, failed linking references

发生这种情况的原因是什么,我该如何解决?

规格:

Android Studio 3.1.2
JRE:1.8.0_152-release-1024-b01 x86_64
构建工具版本:27.0.3
摇篮:4.6
Gradle 插件:3.1.2

编辑:
以防万一我从我们的项目中删除了每一行样式和属性,并进行了干净的构建和缓存失效和重新启动等所有操作,但构建仍然指向values.xmlcom.android.support:appcompat-v7:27.1.1

【问题讨论】:

    标签: android android-gradle-plugin android-appcompat android-styles


    【解决方案1】:

    我遇到了同样的问题,发现主要问题是aapt2没有正确报告问题位置。

    在所有样式 xml 文件中全局搜索 name="@android。 这是&lt;item name="@android:...的一部分

    您需要删除 @ 字符。

    我在其中一个文件中找到了这一行:&lt;item name="@android:textColor"&gt;#FF000000&lt;/item&gt;

    aapt2 正确报告了它发现 @ 字符的其他位置的问题,但由于某种原因,在这种情况下它没有正确报告。

    如果有的话,您可能需要搜索共享文件甚至库 aar 文件。

    【讨论】:

    • 哇。原来是这个原因。我们有一个&lt;item name="@android:textColor"&gt;。删除了@,现在一切正常。我可以再次开始使用 Instant Run。太感谢了! :-)
    • 疯了...我被困了好几个小时!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-10
    相关资源
    最近更新 更多