The development of a mobile application interface begins with a visual component, and the icon is the first thing the user sees on Google Play or on the home screen of their smartphone. Replacing an icon This is not just a cosmetic edit, but an important stage in preparing the project for release, requiring compliance with the strict technical requirements of the platform. Android. Errors at this stage can cause the application to look blurry on some devices or display incorrectly in the system launcher of others.
In a modern development environment Android Studio the process of changing a graphic element has become much easier thanks to built-in tools and support for vector graphics. However, developers still need to understand resource structure, the differences between responsive and round icons, and the correct path to place files in the project directory. Understanding these nuances ensures that your brand will be presented with quality on any screen resolution.
In this article we will analyze in detail the mechanism for working with graphic resources, consider the use Asset Studio to automatically generate all the necessary sizes, and discuss manual editing of manifest files for advanced scenarios. You will learn how to avoid common mistakes when working with res/mipmap and why using low-quality raster images can spoil the impression of the entire product.
Preparing the source image and Google Play requirements
Before opening the IDE, you need to prepare the source image file. The system Android requires that the source be square and have a high resolution so that the scaling algorithms can correctly create versions for screens with different pixel densities. The optimal format for the source is PNG without transparency (although transparency is acceptable, a background color is often preferred for preview purposes), and at least 512x512 pixels in size.
Google Play Console imposes additional restrictions on the image that will be displayed in the app store. It must be in PNG or JPEG format, 512x512 pixels in size and weigh no more than 1024 KB. Critical: Do not add text, store logos or any other elements to the icon that are not part of the application design itself, as this may lead to the publication being rejected by moderators.
โ ๏ธ Attention: The Android Studio interface and resource requirements may be updated with the release of new SDK versions. Always check the official Android developer documentation when working with new API levels to ensure that the resource format you choose is supported by the target OS version.
For a local icon that is displayed on the user's device, the requirements are a little more flexible, but the principle remains the same: the higher quality the source, the better the result on retina displays. It is recommended to use vector formats at the design stage in Figma or Adobe Illustrator, and then export them to a high-resolution raster for import into the project.
Using Image Asset Studio to generate resources
The most reliable and fastest way to replace graphics is to use the built-in wizard Image Asset Studio. This tool will automatically create all the necessary image variations for different screen densities (ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi) and place them in the correct project folders. To launch the wizard, right-click on the folder res in the project window, select New, and then Image Asset.
In the window that opens you will see two main tabs: Legacy and Foreground Layer. The Legacy tab allows you to set a classic square icon that will be used on older versions of Android or as a background for a responsive icon. Here you can select the file path, crop the image and adjust the zoom. The Foreground Layer tab is designed to create adaptive icons introduced in Android 8.0, where the system can dynamically change the shape of the icon (circle, square, drop) depending on the launcher theme.
- ๐จ Path: Specify the path to your image file, selecting the Image option instead of Clip Art if you have a ready-made logo.
- โ๏ธ Trim: Use this function to automatically remove unnecessary transparent fields around the image, centering it.
- ๐ Scaling: Adjust the scaling factor so that the logo occupies the optimal area inside the safe zone (usually 40-50% of the total area).
- ๐ฒ Shape: Select a mask shape for the adaptive icon, although most often this is left to the discretion of the system.
After setting all the parameters, click button Next and then Finish. Android Studio will generate many files in directories mipmap-mdpi, mipmap-hdpi and so on. This saves the developer from manual resizing and ensures that the icon will be clear on any device, from budget smartphones to flagships with 4K displays.
โ๏ธ Checking the generated assets
Mipmap resource structure and adaptive icons
It is important to understand the difference between folders drawable and mipmap. Although it is technically possible to store icons in a drawable, the Android system recommends using mipmap specifically for application icons. The main advantage of mipmap folders is that the system does not unload these resources from memory when the device configuration changes (for example, when the screen is rotated), which ensures smooth operation of the launcher.
Starting with API level 26 (Android 8.0 Oreo), the concept of adaptive icons has been introduced. They consist of two layers: foreground (foreground) and background (background). These layers are described in a special XML file, usually located along the path res/mipmap-anydpi-v26/ic_launcher.xml. The system applies a mask to these layers, which allows the icon to fit harmoniously into any interface design.
| Resource type | Purpose | File format | Use priority |
|---|---|---|---|
ic_launcher.png |
Classic raster icon | PNG | For Android 7.1 and below |
ic_launcher.xml |
Adaptive icon (vector/layer) | XML | For Android 8.0 and above |
ic_launcher_round.png |
Round version of the icon | PNG | For launchers with round theme |
ic_launcher_foreground.xml |
Foreground layer | Vector/XML | Responsive icon component |
If you want full control over the appearance of the icon on new devices, you need to edit the XML descriptors rather than replacing PNG files directly. Otherwise, if you simply overwrite PNGs in mipmap folders, newer devices may display a default mask over your image, sometimes resulting in unwanted visual effects such as important logo details being cut off.
Use vector drawables (VectorDrawable) for responsive icon layers instead of raster PNGs. This will reduce the APK size and provide perfect clarity on screens of any pixel density without the need to generate many files.
Manually editing AndroidManifest.xml
Sometimes automatic generation is not enough, for example, if you want to set different icons for different build variants or for specific activities. In this case, you must manually edit the file AndroidManifest.xmllocated in the folder app/src/main. This is where you specify which resource will be used as the main application icon.
Find the tag <application> and check the attribute android:icon. By default, it links to the resource @mipmap/ic_launcher. If you created a new icon with a different name, for example my_custom_icon, you need to change the attribute value accordingly. It is also worth checking the attribute android:roundIcon, which is responsible for the circular display on supported launchers.
<applicationandroid:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/AppTheme">
Please note that changing the icon in the manifest does not require recompiling the entire project if the resources have already been added, but to apply the changes on the device you will need to reinstall the application. When using Product Flavors you can define different icons for the free and paid versions of the application directly in the corresponding folders src/flavorName/res, overriding resources from the main folder.
โ ๏ธ Attention: When manually changing the paths to resources, make sure that the file names contain only lowercase Latin letters, numbers and underscores. Using capital letters or special characters in resource file names will result in a compilation error.
Clearing the project and cache after replacement
Android Studio has an aggressive caching system that can sometimes retain old versions of resources even after they have been replaced. If you updated the icon, built the project, but still see the old image on the emulator or device, the problem most likely lies in the build cache. This is a common situation that often confuses newbies.
To solve this problem, you need to perform a complete cleanup of the project. In the top menu, select Build, then click Clean Project. After completing this operation, be sure to select Rebuild Project. These actions will force the IDE to re-index all resources and generate new files R.javain which the correct links to the updated images will be written.
- ๐๏ธ Invalidate Caches: If cleaning the assembly did not help, go to
File โ Invalidate Caches / Restartand select the optionInvalidate and Restart. This will reset the internal cache of the development environment itself. - ๐ฑ Uninstall App: On a physical device, the old icon may remain in the launcher even after an update. Completely remove the application from the device before reinstalling.
- ๐ Gradle Sync: Sometimes it helps to simply re-sync the project with the Gradle files via a button
Sync Now.
In some cases, especially when using Instant Run (in older versions) or Apply Changes, resources are not updated on the fly. In such a situation, the only correct solution is to completely reinstall the application via command adb uninstall or manually remove it from the smartphone screen. Ignoring this step may result in you testing an outdated version of the interface.
Why does the icon not change after Rebuild?
Often the problem lies in the fact that the Android launcher caches application icons for performance reasons. Even if the APK contains new graphics, the system displays the old ones from its cache. Solution: delete the application, restart the phone and install again.
Common mistakes and optimization tips
One โโof the most common mistakes is using images with a transparent background for adaptive icons without setting the background color. As a result, on some launchers the icon may look like an object hanging in the void or have a black/white background that does not match the branding. Always set an explicit background color in the layer background or use a solid image for the legacy version.
Also, developers often forget about notification icons. Although this is a separate resource (android:icon in the tag <notification>), the preparation logic is similar. The notification icon must be completely white (alpha channel) on a transparent background, otherwise it may appear as a black square on modern versions of Android. Don't use colored details in status bar icons.
APK size optimization also plays a role. If you use raster images for all densities, the application size may grow unnecessarily. Switching to Vector Drawables allows you to store graphics as XML code, which occupies bytes instead of kilobytes. This is especially true for simple logos and geometric shapes that are easily described by vector paths.
The use of vector graphics and the correct structure of mipmap resources is the key to ensuring that your application will look professional on any device, from an old tablet to the latest foldable smartphone.
Is it possible to use SVG files directly in Android Studio?
You cannot directly use files .svg in application code, since Android does not support this format natively in resources. However, Android Studio automatically converts imported SVG files to VectorDrawable (XML) format when you add them through the import wizard. This is the best way to work with a vector.
Why is the icon in the Google Play Console different from the icon on the phone?
The app store uses a separate high-resolution image (512x512) that you upload to the developer console separately from the APK file. The icon inside the APK (mipmap) is used only after installing the application on the device. They may be visually similar, but technically these are different files.
How to make different icons for the beta version and release?
To do this, you need to use Product Flavors in the file build.gradle. Create flavours beta and release, then place icon files with the same names in folders src/beta/res/mipmap and src/release/res/mipmap. The build system will automatically substitute the required version depending on the selected build task.
What to do if the icon looks blurry on the tablet?
Most likely, the folder mipmap-xxxhdpi has an image of insufficient resolution. Tablets with high pixel density require very high quality source material. Make sure that the generated files for the highest densities were not accidentally replaced with smaller copies.
Is it necessary to create a round icon (roundIcon)?
Technically this is not necessary, the application will launch without it. However, if the attribute roundIcon is not specified, the system may try to crop the main icon to a circle, which often results in losing important elements at the corners. It is recommended to explicitly specify the round version for better design control.