For the pre-64-bit Android support which supports Android 7 and earlier icons, we tried to make things easy on you (well that’s always our goal).
We let you create the 6 icons and give them easy to remember names that included the Android screen density in them:
Icon-xxxhdpi.png
for instance. Then magically behind the scenes during our build process we would move that icon to the appropriate “Android” folder inside the .apk. You didn’t have to worry about having a res folder with a bunch of sub folders in it. Icons were simple then, we knew the exact size and by giving you a very simple naming scheme life was easy.
But Google couldn’t leave well enough alone and came up with Adaptive icons staring with Android 8. These beasts take a background of some sort (PNG file, solid color, etc.) and a foreground image with transparency, and how they can pick the right one for the right screen density and do all kinds of “cool” (questionable) things with it like have rectangular or round icons. Having a separate background allows them to stretch it to fit whatever and plop the main foreground image into place.
To support this we had to mimic the exact folder structure that Android was using. These Icons are intended to be created in Android Studio and have it output everything sized right. But here is where it gets ugly fast.
Android calls these ic_launcher images, not icons. If you use Android Studio, that’s what it’s going to be outputting. So now you have an ic_launcher.png for 7.0 and earlier, an ic_launcher_foreground.png for Android 8 and later and then depending if you’re going for a solid color background or an image background, you might end up with an ic_launcher_background.png file. All of this ends up getting written to some XML files. Then you have a folder for each of the screen densities. It looks like they have dropped the ldpi (low dpi screens) from what they build now.
Now you have a folder structure like this that we put under a folder named AndroidResources:
./res ./res/mipmap-anydpi-v26 ./res/mipmap-anydpi-v26/ic\_launcher.xml ./res/mipmap-hdpi ./res/mipmap-hdpi/ic\_launcher.png ./res/mipmap-hdpi/ic\_launcher\_foreground.png ./res/mipmap-mdpi ./res/mipmap-mdpi/ic\_launcher.png ./res/mipmap-mdpi/ic\_launcher\_foreground.png ./res/mipmap-xhdpi ./res/mipmap-xhdpi/ic\_launcher.png ./res/mipmap-xhdpi/ic\_launcher\_foreground.png ./res/mipmap-xxhdpi ./res/mipmap-xxhdpi/ic\_launcher.png ./res/mipmap-xxhdpi/ic\_launcher\_foreground.png ./res/mipmap-xxxhdpi ./res/mipmap-xxxhdpi/ic\_launcher.png ./res/mipmap-xxxhdpi/ic\_launcher\_foreground.png ./res/values ./res/values/values.xml
We have, in a quest again to make your life simple, pre-built a folder for you. We use the names Android Studio expects since if you decide to customize this, it’s what you’re going to get, so all the XML files will be right and you won’t have to mess with them. In theory you just need to drop your icons in named correctly and be the right size. As such, we have chosen to use a solid color for the background as you can see in the ./res/mipmap-anydpi-v26/ic_launcher.xml file:
\<?xml version="1.0" encoding="utf-8"?\> \<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"\> \<background android:drawable="@color/ic\_launcher\_background"/\> \<foreground android:drawable="@mipmap/ic\_launcher\_foreground"/\>
Since we are asking for a solid color, we go to the res/values/values.xml file:
\<?xml version="1.0" encoding="utf-8"?\> \<resources\> \<color name="ic\_launcher\_background"\>#f4721e\</color\> \</resources\>
and look for a color named ic_launcher_background. I took this code from one of our sample apps, so our foreground images are white Corona icons with transparency and this defined color is our “Orange”.
The regular ic_launcher.png files maintained the size of the old icons you’re used to using, but the new ic_launcher_foreground.png files are overall bigger and I believe are actually the same size, but it adds some transparency around them to give Android flexibility to do things like zoom or crop the images.
We are working on a guide to this, and hopefully will have it published soon.
Every new project you create from the Corona welcome window will have a pre-built AndroidResources folder. You just have to rename your icons and copy them in to place and then make the lc_launcher_foreground versions which I believe are larger, but should be the same as the ic_launcher.png files, just with transparency to make up the size difference.
Resolving the difference between the two icon sizes is something we are still trying to figure out as well as allowing you to use your own images as backgrounds instead of a static color.
But for now and to keep it simple, keep the static color and just copy in and rename your existing icons, and then resize them to the larger size needed for the ic_launcher_foreground files.
Rob