Error: resource identifier for attribute 'srcCompat'

I added 2 images using Copy + Paste in the folder @drawable, but I get an error

 Error:(25) No resource identifier found for attribute 'srcCompat' in package 'com.example.francydarkcool.maps'

I added:

defaultConfig {
 vectorDrawables.useSupportLibrary = true;
 ...
}

in build.gradle

and:

    ImageView img1 = new ImageView(this);
    img1.setImageResource(R.drawable.cascada3);
    setContentView(img1);

    ImageView img2 = new ImageView(this);
    img2.setImageResource(R.drawable.cascada1);
    setContentView(img2);

in my .java file.

This is my activity_cascada_urlatoarea.xml file:

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#479fc7"
    android:orientation="vertical"
    android:weightSum="480">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:weightSum="1"
            android:layout_weight="1"
            android:orientation="vertical" >


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="227dp"
            app:srcCompat="@drawable/cascada3"
            android:id="@+id/imageView5"
            android:layout_weight="0.50"
            />

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="200dp"
                app:srcCompat="@drawable/cascada1"
                android:id="@+id/imageView7"
                android:layout_weight="0.33"
                />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="68dp"
                android:orientation="horizontal"
                android:weightSum="1">

                <Button
                    android:text="Back"
                    android:layout_width="118dp"
                    android:layout_height="29dp"
                    android:id="@+id/button2"
                    android:background="@color/cast_mini_controller_main_background"
                    android:textSize="14sp"
                    android:textStyle="normal|bold"
                    android:textAlignment="center"
                    android:layout_marginTop="30dp"
                    android:onClick="backbttn"
                    android:layout_marginLeft="20dp"/>

                <Button
                    android:text="Next"
                    android:layout_width="118dp"
                    android:layout_height="29dp"
                    android:id="@+id/button8"
                    android:background="@color/cast_mini_controller_main_background"
                    android:textAlignment="center"
                    android:textStyle="normal|bold"
                    android:layout_weight="0.16"
                    android:layout_marginTop="30dp"
                    android:layout_marginLeft="110dp"
                    android:onClick="nextbttn"/>

            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

If I try to change

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

with

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

I do not get errors, but images are not displayed ...

Please, help.

+4
source share
1 answer

make sure that in your build.gradle application , which is under the dependency .. you are using the latest version of the support library (any version 23.3+ will work).

compile 'com.android.support:appcompat-v7:24.1.1'

.

+6

Source: https://habr.com/ru/post/1649761/


All Articles