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

查看:30
本文介绍了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.

任何指针都会很棒!谢谢!它似乎与这个线程有关 但没有提供解决方案:

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

推荐答案

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

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.

所以,对于您来说,由于 lint 检查无法识别 ?attr/selectableItemBackground

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

  1. 找到Gradle__com_android_support_xxx.xml 文件
  2. 删除这些文件
  3. 与文件系统同步 IDE
  4. 使用 Gradle 文件同步项目
  5. 重建您的项目

您可以通过单击工具栏顶部的文件"并选择与文件系统同步"然后选择将项目与 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天全站免登陆