Search code examples
androidbuild.gradleandroid-xmlandroid-drawable

AAPT: error: resource android:drawable/ic_search is private


I made a menu .xml file for an Action Bar in res/menu. Here's my code:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/search"
        android:icon="@android:drawable/ic_search"
        app:showAsAction="always"
        android:title="Search">
    </item>
</menu>

When I try to run my app, I get this error:

AAPT: error: resource android:drawable/ic_search is private.

I tried to clean the project, sync Gradle, etc., write disable PrivateResource in Gradle, write tools:ignore="PrivateResource" in my .xml. But none of this helps.

Thank you for helping me.


Solution

  • I found what I did wrong. I wrote

    android:icon="@android:drawable/ic_search"
    

    But it should be written like this:

    android:icon="@drawable/ic_search"