Learn how to solve the "No resource found (at 'icon' with value '@drawable/icon')" error in your Android app

This error seems to be caused, when you import an old version of a project into Android Studio, then Android Studio will update the gradle version to its latest version causing the error. It seems to happen too with Cordova Projects that have an old version of gradle, when you remove the old android platform using cordova platform remove android and then you reinstall using cordova platform add android.

The error itself and the explanation is pretty simple: since Android 4.3 we can now make use of the res/mipmap folders to store "mipmap" images. e.g. Chrome for Android stores its icons in these folders instead of the more normal res/drawable folders. That means that the icon of your app, the resource @drawable/icon indeed doesn't exists, simply because in recent versions of an Android Project, it will search for it using @mipmap/icon.

Solution 1

As mentioned previously, you need to replace in your AndroidManifest.xml () all the @drawable parameters with @mipmap. Try to rebuild again, if the problem persists, which error will be thrown by the console in the manifest located in the folder /android/build/intermediates/manifests/full/debug/AndroidManifest.xml, then try to modify all the AndroidManifest.xml files located in your project. 

Change, for example in /debug/AndroidManifest.xml :

<application
        android:hardwareAccelerated="true"
        android:icon="@drawable/icon"
        ...
>

To:

<application
        android:hardwareAccelerated="true"
        android:icon="@mipmap/icon"
        ...
>

This solution seems to work for most of the developers, besides it works in Cordova and Xamarin too. After the change, don't forget to rebuild the project in Android Studio or if you're using cordova, use cordova prepare and then cordova build.

Solution 2

For some developers, what worked instead is to create a new folder in /platforms/android/res/ with the name drawable and put the icon of your app inside with the name icon.png. However, in many project this folder and the icon seems to already exists, therefore this solution is most likely to fail.

May the force be with you !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors