AAPT: error: resource drawable/example (aka com.app:drawable/example) not found

Viewed 5033

I added one shape to the drawable folder as follows;

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:color="#7A828D" android:width="1dp"/>
    <solid android:color="@color/white" />
    <corners android:radius="8dp"/>
</shape>

Then I included this in my layout;

<androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="64dp"
            android:background="@drawable/shape_info_bg_1"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintBottom_toTopOf="@id/sl_userid"
            android:layout_marginBottom="20dp">
            <ImageView
                android:id="@+id/img_info"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:src="@drawable/ico_info"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                android:layout_marginStart="20dp"
                />
            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                tools:text="asdasdasdasda"
                android:fontFamily="@font/medium"
                android:layout_marginEnd="50dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/img_info"
                app:layout_constraintTop_toTopOf="@id/img_info"
                app:layout_constraintBottom_toBottomOf="@+id/img_info"
                android:layout_marginStart="15dp"/>
        </androidx.constraintlayout.widget.ConstraintLayout>

and when i get build on real device i get the following errors;

...\src\main\res\layout\activity_login.xml:41: AAPT: error: resource drawable/shape_info_bg_1 (aka com.xxxxx:drawable/shape_info_bg_1) not found.

    AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\xxxx\\Documents\\xxxx\\app\\src\\main\\res\\layout\\activity_login.xml","position":{"startLine":40}}],"original":"C:\\Users\\xxxx\\Documents\\xxxx\\app\\src\\main\\res\\layout\\activity_login.xml:41: AAPT: error: resource drawable/shape_info_bg_1 (aka com.xxxx:drawable/shape_info_bg_1) not found.\n    ","tool":"AAPT"}

> Task :app:mergeExtDexDebug

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\xxxxx\Documents\xxxxx\app\src\main\res\layout\activity_login.xml:41: AAPT: error: resource drawable/shape_info_bg_1 (aka com.xxxxx/shape_info_bg_1) not found.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BU�LD FAILED in 12s

I always add shape in this way and there is no problem. I could not solve this problem. I have never met before, can you help me?

3 Answers
  1. Delete The File And Build The Project.

  2. Create The File again which you have deleted.

Just hit clean the project Then make a rebuild

It will surely fix your problem. If it wont, just delete the file you added, rebuild the project, add file again and build the project

I got this error in a project I inherited which had just been updated from NativeScript 4 to NativeScript 6.

The resolution for me was to move the resource folders to the correct location so the build would pick them up and add them to the output build folders:

'app/App_Resources/Android/' to 'app/App_Resources/Android/src/main/'
'app/App_Resources/Android/drawable...' to 'app/App_Resources/Android/src/main/res/drawable...'
'app/App_Resources/Android/values' to 'app/App_Resources/Android/src/main/res/values'

Fissh

Related