拂心L 2021-04-28 17:36 采纳率: 0%
浏览 115

求帮助,谢谢! Android resource linking failed 出现这样的报错怎

求帮助,谢谢! Android resource linking failed 出现这样的报错怎么解决? AAPT : error : style attribute ' att " colorPrimaryVariant ( aka comJmooc . aivoiceapp : att " colorPrimaryVariant )' not found .
  • 写回答

1条回答 默认 最新

  • 码农阿豪@新空间 新星创作者: 前端开发技术领域 2024-07-14 19:22
    关注
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    问题描述:在Android项目中出现了资源链接失败的错误,报错信息为AAPT: error: style attribute 'att' colorPrimaryVariant (aka comJmooc.aivoiceapp:att'colorPrimaryVariant)' not found. 解决方法:
    1. 检查XML文件中的属性名是否拼写正确,确保不存在拼写错误或大小写错误。
    2. 确保资源文件中包含了相应的属性定义,比如确保colors.xml或themes.xml文件中有colorPrimaryVariant属性的定义。
    3. 确保使用的属性名和命名空间正确匹配,比如确保使用的属性名中不包含额外的空格或特殊字符。
    4. 如果使用的是第三方库或框架的属性,可能需要查看对应文档或源码,确定属性名的正确写法。 示例代码: 比如在res/values/themes.xml文件中定义了colorPrimaryVariant属性:
    <resources>
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
            <item name="colorPrimaryVariant">@color/colorPrimaryVariant</item>
        </style>
    </resources>
    

    然后在XML布局文件或代码中使用:

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World"
        android:textColor="?attr/colorPrimaryVariant" />
    

    通过以上步骤可以解决Android资源链接失败的错误。

    评论

报告相同问题?