我收到 Error:(26) No resource identifier found for attribute 'srcCompat' in package 'learnapp.android.example.com.learnapp'
当我尝试运行我的应用程序时。我今天刚开始学习 android。我添加了一个新 Activity 并试图更改任何 xml 文件中的任何内容。
这是确切的错误:
Documents/MyProjects/LearnApp/app/src/main/res/layout/activity_display_message.xml
Error:(26) No resource identifier found for attribute 'srcCompat' in package 'learnapp.android.example.com.learnapp'
这是我的 activity_display_message.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="learnapp.android.example.com.learnapp.DisplayMessageActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_display_message" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</LinearLayout>
我已经阅读了类似的问题,并且看到了这行
xmlns:app="http://schemas.android.com/apk/res-auto"
或
app:srcCompat="@android:drawable/ic_dialog_email" />
他们的情况是错误的,而我的情况不是。
如果重要的话,这个 Activity 的父 Activity 是 MainActivity.java
最佳答案
我只是变了
xmlns:app="http://schemas.android.com/apk/res-auto"
到
xmlns:app="http://schemas.android.com/apk/lib/my_package_name"
我看到了答案here
关于android - 在包 'srcCompat' 中找不到属性 'learnapp.android.example.com.learnapp' 的资源标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38161864/