prabhatsdp
prabhatsdp

Reputation: 129

Android resource linking failed for all the drawable files - Android

I am unable to build my Android project. It is throwing 21 build errors for each of my drawables referenced at different layouts. The error says -

ERROR:\app\src\main\res\drawable\bg_btn_submit_accent.xml:11: AAPT: error: resource drawable/ripple_accent (aka in.crazybytes.some_app_android:drawable/ripple_accent) not found.
    

It says drawable/ripple_accent not found even though the XML file is already present in the drawable folder. Below is the code of both files.

bg_btn_submit_accent.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_enabled="false">
        <shape android:shape="rectangle">
            <solid android:color="@color/text_color_subtitle"/>
            <corners android:radius="8dp" />
        </shape>
    </item>

    <item android:state_enabled="true" android:drawable="@drawable/ripple_accent"/>
    <item android:drawable="@drawable/ripple_accent"/>

</selector>

ripple_accent.xml

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/green_700">
    <item android:id="@android:id/mask">
        <shape android:shape="rectangle">
            <solid android:color="@color/green_700" />
            <corners android:radius="8dp" />
        </shape>
    </item>

    <item android:id="@android:id/background">
        <shape android:shape="rectangle">

            <solid android:color="@color/green_500" />
            <corners android:radius="8dp" />
        </shape>
    </item>

    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/green_500" />
            <corners android:radius="8dp" />
        </shape>
    </item>

</ripple>

I tried Invalidate cache and Restart but it didn't work. Please help me out, guys.

Upvotes: 0

Views: 3561

Answers (1)

prabhatsdp
prabhatsdp

Reputation: 129

After @DavidLee suggested, I checked all of my XML files for errors one by one and found out that some of the files were missing the first line of code.

<?xml version="1.0" encoding="utf-8"?>

It is perhaps because of an online tool I used to bulk generate some drawables from SVGs.

The code is now working after adding the missing line above.

Upvotes: 1

Related Questions