No resource identifier found for attribute 'srcCompat' in package 'learnapp.android.example.com.learnapp'

前端 未结 9 1430
滥情空心
滥情空心 2020-12-18 18:02

I am getting Error:(26) No resource identifier found for attribute \'srcCompat\' in package \'learnapp.android.example.com.learnapp\' when I try to run my app.I

相关标签:
9条回答
  • 2020-12-18 18:22

    I just changed

    xmlns:app="http://schemas.android.com/apk/res-auto" 
    

    to

    xmlns:app="http://schemas.android.com/apk/lib/my_package_name"
    

    I saw the answer here

    0 讨论(0)
  • 2020-12-18 18:28

    I'm using the srcCompat api as follows.

    <android.support.v7.widget.AppCompatImageView
          android:id="@+id/dashboard"
          android:layout_width="60dp"
          android:layout_height="60dp"
          srcCompat="@drawable/dash">
    

    More info

    0 讨论(0)
  • 2020-12-18 18:30

    Happens if you start updating Android Studio and canceled the update midway complete the update process and everything should be back to normal

    0 讨论(0)
  • 2020-12-18 18:31

    Also happens when you have outdated versions of the support libraries.

    I updated from:

    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    

    to:

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    

    (those were the newest versions at the moment I wrote this)

    and the error is gone.

    0 讨论(0)
  • 2020-12-18 18:35

    change app:srcCompat="@android:drawable/ic_dialog_email" for

    android:src="@android:drawable/ic_dialog_email"
    
    0 讨论(0)
  • 2020-12-18 18:37

    Add this vectorDrawables.useSupportLibrary = true to your app level build.gradle

    defaultConfig {
        ...
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
    }
    
    0 讨论(0)
提交回复
热议问题