Image Optimization (Android)

Android

Images stored as PNG or JPEG that would be significantly smaller in WebP format. PNG-to-WebP conversion typically saves 26% lossless or 25-34% lossy vs JPEG.

Images and drawable resources are frequently the second-largest contributor to APK size after native libraries. WebP offers superior compression over JPEG and PNG while maintaining visual quality, supported since Android 4.2.1 (API 17) for lossy and lossless with alpha. AVIF provides even better compression using AV1 encoding, supported since Android 12 (API 31). Choosing the right format per asset type and aggressively optimizing existing images can yield significant size savings.


Why this happens

  • Unoptimized PNGs: PNG files often contain unnecessary metadata, full alpha channels on opaque images, and unoptimized compression tables.

  • JPEG/PNG used where WebP is better: Many projects still default to legacy formats despite WebP offering 25-34% better compression.

  • Multi-density raster assets: Providing PNG/JPEG variants at ldpi/mdpi/hdpi/xhdpi/xxhdpi/xxxhdpi multiplies storage 5-6x for each image.

  • Large embedded photos: Hero images, onboarding screens, and marketing assets stored as unoptimized bitmaps at full resolution.

  • Unused alpha channels: PNGs saved with transparency (32-bit RGBA) when the image is fully opaque (24-bit RGB would suffice) waste 25% of the per-pixel storage.


Size impact

Image format conversion is one of the highest-ROI optimizations with minimal effort.

WebP lossless vs PNG

26% smaller on average

WebP lossy vs JPEG

25-34% smaller at equivalent quality

WebP lossy with alpha vs PNG

3x smaller

PNG indexed color (256 colors)

75% reduction per pixel


How we detect it

Scans the res/ directory of the APK for PNG and JPEG files, sorted by size. Android Studio's "Convert to WebP" tool shows estimated savings before conversion. Lint inspections ConvertToWebp and IconMissingDensityFolder help identify conversion candidates.


How to fix

1

Convert PNG/JPEG to WebP in Android Studio

Right-click image files or folders > "Convert to WebP". Set lossy encoding quality to 75% as a starting point. Skip 9-patch files as they do not support WebP.

2

Disable PNG crunching when using WebP

Avoid double-processing by disabling aapt PNG optimization when images are already optimized.

build.gradle.kts

android { buildTypes { release { isCrunchPngs = false } } }

3

Use AVIF for Android 12+ targets

Provide AVIF with a WebP fallback using resource qualifiers for maximum compression on newer devices.

Resource qualifiers

// res/drawable-v31/hero_image.avif (AVIF for API 31+) // res/drawable/hero_image.webp (WebP fallback)

4

Optimize remaining PNGs

For PNGs that must remain as PNG (9-patch files), use lossless compression tools like pngquant or zopflipng to reduce file size.

# Lossy PNG optimization (60-80% quality) pngquant --quality=65-80 --output output.png input.png # Aggressive lossless compression zopflipng --iterations=15 input.png output.png

5

Reuse drawable resources with tinting

Instead of shipping separate colored icons, use a single icon and apply tints at runtime to reduce the number of drawable files.

Important: 9-patch images cannot be converted to WebP. AVIF decoding in Android 12 and 13 has known bugs (transparent background issues, decoding glitches) and is more reliable from Android 14+. Always visually verify lossy WebP/AVIF output, as artifacts are more visible on gradients and text overlays. Strip EXIF and GPS metadata from JPEGs before inclusion.


Powered by Bitrise, trusted by 8,500+ brands

Size Analyzer is built by Bitrise, the leading mobile DevOps platform used by over 400,000 developers at companies like Shopify, TripAdvisor, and BuzzFeed. Free forever. No signup required.

Bitrise provides a full-stack mobile DevOps solution that unites the tools, processes, and testing frameworks engineering teams need to ship best-in-class mobile experiences.

Bitrise logo