0

I have another activity whose layout has RelativeLayout, TextViews and an ImageView...no problems here.

With this other Activity below I have many TextViews and a RelativeLayout. When I add an Imageview, I receive the following errors:

Error:(190) No resource identifier found for attribute 'srcCompat' in package 'com.example.ftonyan.userposts' Error:(190) No resource identifier found for attribute 'srcCompat' in package 'com.example.ftonyan.userposts' Error:Execution failed for task ':app:processDebugResources'.

com.android.ide.common.process.ProcessException: Failed to execute aapt

The top part of the layout.xml for this problematic activity looks as follows before the imageview is added (the code compiles and runs on the emulator)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

After the imageview is added to the palette the following 2 lines are red (note the 2nd line was added by the system). The code no longer compiles.

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

Below is my Activity layout.xml. There are approximately 19 textViews in this layout. I did not include all of them for the sake of brevity.

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">


    <TextView
        android:id="@+id/lblAddressees"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/lblNick"
        android:layout_toStartOf="@+id/nickName"
        android:text="Addressees:" />

    <Button
        android:id="@+id/goBack"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:background="@android:color/transparent"
        android:text="back" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button6"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="87dp"
        android:srcCompat="@mipmap/ic_launcher" />

</RelativeLayout>

I have read a few posts here recommending a change to the apk/res-auto line. However, that line is not in the file in the first place until the system adds it. So, not sure what I am supposed to do to fix this. Thanks in advance

Frank Zappa
  • 451
  • 2
  • 11
  • 23

5 Answers5

1

In your project open app level build.gradle file add the following lines

defaultConfig {
   vectorDrawables.useSupportLibrary = true
}

And sync your project. That's it.

Shashanth
  • 4,995
  • 7
  • 41
  • 51
0

You need to add namespace code for the Imageview

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

The namespace 'schemas.android.com/tools' is for specifying options to build the app by Android Studio, and are not included in the final app package

The namespace 'schemas.android.com/apk/res-auto' is used for all custom attributes - defined in libraries or in code.

pradeep
  • 307
  • 1
  • 8
  • Error:(190) No resource identifier found for attribute 'srcCompat' in package 'com.example.ftonyan.userposts' Error:(190) No resource identifier found for attribute 'srcCompat' in package 'com.example.ftonyan.userposts' Error:Execution failed for task ':app:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt – Frank Zappa Apr 09 '17 at 14:23
0

I figured it out. I was missing this line

tools:context="packagename.nameofAttivity">

Thanks everyone

Frank Zappa
  • 451
  • 2
  • 11
  • 23
0

Check This Android image not showing in imageview

In This Post as I have told this --- ...... You should edit srcCompat to src. src is meant for source and sourceCompat Is for Backwards Compatiblity Of Vector Drawable Files For Android Devices Running On and below ICS -- IceCream Sandwich.

Community
  • 1
  • 1
Anuj Kumar
  • 1,092
  • 1
  • 12
  • 26
0

First of all there's no need to add android:srcCompat to set default image.

Because app:srcCompat is used for backwards compatibility with vector drawables for the support library.

Try android:src="@mipmap/ic_launcher" or android:background="@mipmap/ic_launcher" instead.

But still if you want to use srcCompat attribute then just change android:srcCompat to app:srcCompat in ImageView.

MashukKhan
  • 1,946
  • 1
  • 27
  • 46