Addaptive Icons with cordova-res

I used cordova-res v0.6.0 to generate adaptive icons. I have an icon.png in /resources and an icon-foreground.png and an icon-background.png in /resources/android.

I create the icons with cordova-res without any parameters. After it is run there are a lot of generated icons in /resources/android/icon:
*-background.png
*-foreground.png
drawable-*-icon.png

And these icons are correctly referenced in config.xml. But when I build my app and install it on my Google Pixel 3 phone (Andorid 9) it still has such a small launcher icon.

Are there any special requirements for icon-foreground.png and icon-background.png for getting a launcher icon that fills the whole icon? I used the “old” icon as foreground icon and a completely white icon in the same size as background icon.

Additional Info:
I created the icon-foreground.png and icon-background.png with Image Asset Studio.
icon-background.png
icon-background

icon-foreground.png
icon-foreground

Resulting launcher icon on my Google Pixel 3:
launcher-icon

What I want to get is something similar to that:
launcher-icon2

It seems that icon-foreground.png and icon-background.png are ignored. When I change the icon.png in /resources to the default Ionic icon this is used instead of foreground and background.

I tried to remove the src attribute from config.xml, but then I get an error:
One of the following attributes are set but missing the other for the density type: ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi. Please ensure that all require attributes are defined.

Any ideas what’s going wrong here?

Noone ever used cordova-res? Or is it working for you?

If it is working for you it would be great if you could post your command for generating the resources. And maybe a background and a foreground icon so I could get an idea what’s wrong on my side.

Any ideas? What can I try to get an adaptive icon that displays full size?

It’s solved. I had to update to Cordova 9 for getting it to work.

Was your final solution using Studio Image Asset images or using cordova-res. I am on Cordova@9 and cordova-android@8.1 and I could only get cordova-res to work - but its not working correctly. My app icon looks like its zoomed in on, opposite of your issues/images you posted earlier. Its like my icon is blown up and the pixel3 circle is just the inner 50% of that blown up image.

Using Studio Image Asset - I create a new image, dropped in my logo icon and it generates all the files - but it never generates the ic_launcher_foreground.xml file. That file is referenced in both ic_launcher.xml and ic_launcher_round.xml - and without the foreground xml file, the build fails.

I have spent probably 10+ hours on these stupid adaptive icons and I can’t get either method to work correctly. beyond frustrated.

1 Like