【问题标题】:Error using Android Design Support Library: attr backgroundTint not found使用 Android 设计支持库时出错:找不到 attr backgroundTint
【发布时间】:2015-06-02 17:26:36
【问题描述】:

尝试在我的项目中使用新的设计支持库,AAPT 抛出以下错误:

Description: Error: No resource found that matches the given name: attr 'backgroundTint'.
Resource:    /design/res/values/styles.xml
Location:    line 21 

这是styles.xml中受影响的条目:

<style name="Widget.Design.FloatingActionButton" parent="android:Widget">
    <item name="android:background">@drawable/fab_background</item>
    <item name="backgroundTint">?attr/colorAccent</item>
    <item name="fabSize">normal</item>
    <item name="elevation">@dimen/fab_elevation</item>
    <item name="pressedTranslationZ">@dimen/fab_translation_z_pressed</item>
    <item name="rippleColor">?attr/colorControlHighlight</item>
    <item name="borderWidth">@dimen/fab_border_width</item>
</style>

我的项目目标是使用 SDK 21,最小 SDK 设置为 17。

编辑:我的所有 SDK 工具都是最新的。

【问题讨论】:

  • 你有这个更新的 Android 支持库、Android 支持存储库、Google Play 服务、Google 存储库吗???
  • @Elenasys 是的,我已经安装并更新了它们。

标签: android eclipse adt


【解决方案1】:

将 appcompat-v7 库添加为设计库项目的依赖项。它为我解决了同样的错误。我觉得对你有帮助。

【讨论】:

  • 您是否在任何 Eclipse 项目中集成了设计库。您是否还需要选中“是库”复选框。对我来说,导入设计支持库时未选中。
  • 是的,我已经在我的 Eclipse 中集成了设计库。对我来说,它也是未经检查的。我们需要通过选中复选框来更改为库项目。
  • @HarshalK,我已经添加了 appcompat-v7 参考并将导入的项目标记为库。问题是别的。
  • 这应该更高,解决了我的问题没问题 - 谢谢。
  • 这正是问题所在。谢谢!
【解决方案2】:

我能够用@igece 解决方案解决这个问题,但后来我发现真正的问题是一个过时的appcompat-v7 library

将其升级到最新版本后,无需在 Google 的库中进行任何编辑。

【讨论】:

    【解决方案3】:

    似乎解决了将format 属性添加到/res/values/attrs.xml 中的backgroundTintbackgroundTintMode 项目:

    之前:

    <declare-styleable name="FloatingActionButton">
        <!-- Background for the FloatingActionButton -->
        <attr name="android:background"/>
        <attr name="backgroundTint"/>
        <attr name="backgroundTintMode"/>
    

    之后:

    <declare-styleable name="FloatingActionButton">
        <!-- Background for the FloatingActionButton -->
        <attr name="android:background"/>
        <attr name="backgroundTint" format="color"/>
        <attr name="backgroundTintMode" format="integer"/>
    

    【讨论】:

    • 现在的问题是我无法对设计支持库类进行任何引用。一遍又一遍地检查我项目中的 Java Build Paths 配置,以确保有对支持库的引用。
    【解决方案4】:

    如果您已经安装了更新的 Android Support Repository 和 Google Play Services,则在设计库项目的依赖项中添加 appcompat-v7 库是解决此问题的方法。

    【讨论】:

      【解决方案5】:

      我想将此作为注释添加到第三个答案下,但代码格式不正确。我必须在下面添加两个依赖项才能解决问题:

      compile 'com.android.support:appcompat-v7:25.3.1'
      compile 'com.android.support:design:25.3.1'
      

      【讨论】:

        猜你喜欢
        • 2015-10-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多