+-
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文件中的资源引用.

<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"/>

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

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

任何指针都会很棒!谢谢!
它似乎与此thread有关,但没有提供解决方案:

最佳答案
我相信这是IDE和Android Gradle插件的通信问题.在任何情况下,我可靠地找到解决此问题的唯一方法是删除.idea / libraries /文件夹中有问题的库.

所以,对你而言,由于lint检查无法识别?attr / selectableItemBackground

>找到Gradle__com_android_support_xxx.xml文件
>删除这些文件
>带文件系统的SYNC IDE
>带有Gradle文件的SYNC项目
>重建您的项目

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

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

这些解决方案也没有帮助……

>使缓存无效/重新启动不起作用.
>清理/重建项目.

点击查看更多相关文章

转载注明原文:Android无法解析符号’?attr / selectableItemBackground’ - 乐贴网