Android Icon Generation
Generate the full Android launcher icon set — five mipmap density buckets, both legacy and adaptive variants, the adaptive icon XML files, and the ic_launcher_background color entry in values/colors.xml — from a single source logo. Sharp-only — no AI, no API keys. Same output as Android Studio's Asset Studio, but local and instant.
generate-android-icons
# Auto-detect logo in Assets/ and write to MobileApp/composeApp/src/androidMain/res
kappmaker generate-android-icons
# Explicit source + brand-colored adaptive background
kappmaker generate-android-icons --source ./Assets/logo.png --background "#0F0A0D"
# Tighter foreground padding (logo fills more of the adaptive canvas)
kappmaker generate-android-icons --foreground-padding 0.1
Flow
- Resolves source —
--source <path>if given; otherwise auto-detects inAssets/looking forlogo.png,logo_no_bg.png,app_logo.png,app_logo_no_bg.png,icon.png(in that order). Prompts interactively if none found. - Center-crops to a square (warns if source is non-square or smaller than 432×432).
- For each of 5 density buckets —
mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi:- Writes
ic_launcher.webpandic_launcher_round.webpat legacy size (48/72/96/144/192px). - Writes
ic_launcher_foreground.webpat adaptive size (108/162/216/324/432px) with the logo centered in the inner safe zone and transparent surround.
- Writes
- Writes
mipmap-anydpi-v26/ic_launcher.xmlandic_launcher_round.xml— adaptive-icon definitions referencing@color/ic_launcher_backgroundand@mipmap/ic_launcher_foreground. - Upserts
<color name="ic_launcher_background">invalues/colors.xml— creates the file if missing, replaces the value if present, inserts the entry alongside any other colors otherwise. - Overwrites existing files silently.
Output
Default path follows the KAppMaker KMM convention:
MobileApp/composeApp/src/androidMain/res/
├── mipmap-mdpi/
│ ├── ic_launcher.webp (48×48)
│ ├── ic_launcher_round.webp (48×48)
│ └── ic_launcher_foreground.webp (108×108)
├── mipmap-hdpi/
│ ├── ic_launcher.webp (72×72)
│ ├── ic_launcher_round.webp (72×72)
│ └── ic_launcher_foreground.webp (162×162)
├── mipmap-xhdpi/
│ ├── ic_launcher.webp (96×96)
│ ├── ic_launcher_round.webp (96×96)
│ └── ic_launcher_foreground.webp (216×216)
├── mipmap-xxhdpi/
│ ├── ic_launcher.webp (144×144)
│ ├── ic_launcher_round.webp (144×144)
│ └── ic_launcher_foreground.webp (324×324)
├── mipmap-xxxhdpi/
│ ├── ic_launcher.webp (192×192)
│ ├── ic_launcher_round.webp (192×192)
│ └── ic_launcher_foreground.webp (432×432)
├── mipmap-anydpi-v26/
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
└── values/
└── colors.xml (← ic_launcher_background entry)
Falls back to MobileApp/androidApp/src/main/res/ → app/src/main/res/ → Assets/android/res/. Override with --output <dir>.
Options
| Flag | Description | Default |
|---|---|---|
--source <path> | Source logo PNG (≥ 432×432 recommended) | Auto-detect in Assets/ |
--output <dir> | Output Android res/ directory | Auto-detect under MobileApp/ |
--background <hex> | Adaptive icon backdrop color (written to colors.xml) | #FFFFFF |
--foreground-padding <ratio> | Padding each side of the adaptive foreground (0–0.5) | 0.25 |
Requirements
None — no API keys, no network. Just a source PNG.
Tips
- Chain with
create-logo— generate the logo, then rungenerate-android-icons(andgenerate-ios-icons) to mint both platforms' icon sets right after. - Source should be at least 432×432 for crisp adaptive foregrounds on xxxhdpi devices. Smaller sources are upscaled (with a warning).
- The default
--foreground-padding 0.25matches Android Asset Studio's default — content occupies the inner 50% of the foreground frame, leaving 25% margin on each side (Android's adaptive icon safe zone). Drop to0.1if your logo is small and should fill more of the adaptive frame; raise to0.4if it's busy and you want more breathing room. - The adaptive
--backgroundis referenced by the generated XML — Android renders this color behind the foreground on Android 8+ devices. On legacy launchers (pre-API 26), the legacyic_launcher.webpis used directly. AndroidManifest.xmlshould already reference@mipmap/ic_launcherand@mipmap/ic_launcher_round. This command doesn't touch the manifest.