App Icon displayed only in API21 but fails in other api's

484 views Asked by At

I have this code in my Manifest file. The problem that I'm facing is that the icon is being displayed only in Android Lollipop (Api21, Asus Nexus Tab). I've tested in Oreo (Oppo A3S)and Android P (Samsung Galaxy S10+) but the icon is not being displayed. The images in the mipmap look fine though.

 <application
        android:name=".Application"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning">

Only a solid color (the background of the icon) is being displayed. Does this have something to do with the images in mipmap? because they look fine. Even the preview of the icon near the line numbers in the manifest looks fine.

I also observed that I just have a webp file in my mipmap-anydpi-v26 but other apps have 2 XML files, one for round and a normal one.

2

There are 2 answers

0
Anirudh Ganesh On BEST ANSWER

Apparently, it was because of the missing XML files inside mipmap-anydpi-v26. I had both the XML files inside drawable.

Looked up for similar files in other projects and came to know that both the XML files basically contain tag followed by background and foreground tags inside it.

The attributes of these two tags basically refer to the files in the drawable folder. most probably background would be a layout resource file with tag inside it representing the background color for the icon and the foreground would be a vector.

But deleting all the mipmaps and regenerating them according to https://developer.android.com/studio/write/image-asset-studio#create-notification should also work.

1
Rajnish Sharma On

You should add the launcher icon the right way. First delete all your ic_launcher and all its versions from mipmap. Now create new image asset with icon type as launcher icon(legacy only) or (adaptive and legacy). Then name it ic_launcher and select your image path and set padding, color, etc then next and finish. It will automatically take the asset as launcher icon in manifest. If not set it manually.

android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"