Android无法解析符号“?attr/selectableItemBackground" [英] Android Cannot resolve symbol '?attr/selectableItemBackground'

查看:421
本文介绍了Android无法解析符号“?attr/selectableItemBackground"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/card_outer_padding"
    android:layout_marginTop="@dimen/card_outer_padding"
    android:layout_marginRight="@dimen/card_outer_padding"
    android:layout_marginBottom='@{model.cardBottomMargin}'
    android:foreground="?attr/selectableItemBackground"
    android:onClick="@{model::onCardClick}"
    app:cardElevation="2dp"
    app:cardCornerRadius="2dp"
    app:cardUseCompatPadding="true">
</android.support.v7.widget.CardView>

我收到此错误消息

无法解析符号?attr/selectableItemBackground 验证Android XML文件中的资源引用.

Cannot resolve symbol ?attr/selectableItemBackground Validates resource references inside Android XML files.

<TextView
    android:id="@+id/country_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="40dp"
    android:text="@{model.name}"
    style="@style/TextAppearance.AppCompat.Headline"
    tools:text="Country"/>

而且,我也遇到了类似的错误

And, I got a similar error for the above as well

无法解析符号'@ style/TextAppearance.AppCompat.Headline'
验证Android XML文件中的资源引用.

Cannot resolve symbol '@style/TextAppearance.AppCompat.Headline'
Validates resource references inside Android XML files.

任何指针都很棒!谢谢! 它似乎与此线程 a>但未提供解决方案:

Any pointer would be great! Thank you! It seems to be related to this thread but no solution was provided:

推荐答案

我认为这是IDE和Android Gradle插件的通信问题.无论如何,我可靠找到解决的唯一方法是删除.idea/libraries/文件夹中有问题的库.

I believe this is a communication problem with the IDE and Android Gradle Plugin. In any case, the only way I've reliably found to resolve this is to delete the problematic libs in the .idea/libraries/ folder.

因此,对您来说,由于皮棉检查无法识别?attr/selectableItemBackground

So, for you, since the lint checks aren't recognizing ?attr/selectableItemBackground

  1. 找到Gradle__com_android_support_xxx.xml文件
  2. 删除这些文件
  3. 具有文件系统的SYNC IDE
  4. 带有Gradle文件的SYNC项目
  5. 重建您的项目
  1. LOCATE the Gradle__com_android_support_xxx.xml files
  2. DELETE those files
  3. SYNC IDE with file system
  4. SYNC project with Gradle files
  5. REBUILD your project

您可以通过单击工具栏顶部的文件"并选择与文件系统同步",然后选择与gradle文件同步项目"来进行同步.

我尝试了其他建议的解决方案-在我的模块build.gradle文件&中具有appcompat-v7依赖项google()存储库作为项目build.gradle依赖项的第一行.娜达.

You can sync by clicking on 'File' at the top by the toolbar and selecting "Sync with File System" and then afterwards selecting "Sync project with gradle files".

I've tried other suggested solutions - had the appcompat-v7 dependency in my module build.gradle file & the google() repository as the first line in the project build.gradle dependencies. Nada.

这些解决方案也无济于事...

These solutions also haven't helped...

  • 使缓存无效/重启无效.
  • 清洁/重建项目.

这篇关于Android无法解析符号“?attr/selectableItemBackground"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆