Jaison_Joseph Jaison_Joseph - 4 years ago 325
Android Question

Error:(34) No resource identifier found for attribute 'srcCompat' in package 'com.hackerinside.jaisonjoseph.radioplanet'

when i add an image to the card view i am geting error like
Error:(34) No resource identifier found for attribute 'srcCompat' in package 'com.hackerinside.jaisonjoseph.radioplanet'

this is my content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/Relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"

app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.hackerinside.jaisonjoseph.radioplanet.MainActivity"
tools:showIn="@layout/activity_main">


<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />

<android.support.v7.widget.CardView
android:layout_width="350dp"
android:layout_height="200dp"
app:cardElevation="10dp"
android:id="@+id/card"
android:layout_above="@+id/button"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dp"
android:layout_marginTop="20dp">


<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@mipmap/ic_launcher"
android:id="@+id/imageView" />
</android.support.v7.widget.CardView>



Answer Source

Avoid using srcCompat, srcCompat attribute is actually defined within AppCompat library:

Replace this:

app:srcCompat="@mipmap/ic_launcher"

With this:

android:src="@mipmap/ic_launcher"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download