Mobile Development 18 min read

Techniques for Reducing Android APK Size in Meituan App

To shrink Meituan’s Android APK, developers can optimize the ZIP layout, enable ProGuard/R8 dex shrinking, inline R fields, convert images to WebP or VectorDrawable, disable redundant PNG crunching, activate shrinkResources, limit packaged languages, obfuscate resources with tools like AndResGuard, and eliminate duplicate or unused assets.

Meituan Technology Team
Meituan Technology Team
Meituan Technology Team
Techniques for Reducing Android APK Size in Meituan App

As Meituan’s app rapidly adds new business logic, image resources, and third‑party SDKs, the APK size keeps growing, leading to higher CDN costs, lower installation success rates, and potential impact on user retention. This article shares a series of practical techniques for shrinking the APK.

APK Composition

An APK is a ZIP archive. By opening it with a ZIP tool you can see the main parts: compiled code (classes.dex), resources (res/), AndroidManifest.xml, resources.arsc, and various Java resources such as org/, src/, push_version, etc. Understanding these components is the first step to optimization.

Zip Format Optimization

Many files in the APK are stored uncompressed (Stored) because they are already compressed formats (e.g., .jpg, .png, .mp3). The AAPT source defines a list of extensions that are not compressed:

/* these formats are already compressed, or don't compress well */
static const char* kNoCompressExt[] = { ".jpg", ".jpeg", ".png", ".gif", ".wav", ".mp2", ".mp3", ".ogg", ".aac", ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet", ".rtttl", ".imy", ".xmf", ".mp4", ".m4a", ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", ".amr", ".awb", ".wma", ".wmv", ".webm", ".mkv" };

Changing the compression method for these files can reduce size, but must be done carefully.

Classes.dex Optimization

Maintain good coding habits, remove dead code, avoid unnecessary third‑party libraries.

Enable ProGuard (or R8) to shrink, obfuscate, and optimize bytecode. In build.gradle set minifyEnabled true and configure proguardFiles:

android {
    ...
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

After ProGuard runs, mapping files show which classes have been removed, e.g., android.support.multidex.MultiDex.

R Field Optimization

Inlining R fields via bytecode manipulation (using Javassist or ASM) can reduce the number of R references and help avoid the 64K method limit.

Resource Optimization

Image Optimization : Choose the appropriate format—VectorDrawable for simple icons, WebP for most images, PNG for transparency‑required assets. Use tools such as pngcrush , pngquant , or zopflipng for PNG, and packJPG or guetzli for JPEG.

Disable AAPT’s automatic PNG crunching when you have already optimized images:

aaptOptions {
    cruncherEnabled = false
}

Resource Compression : Set shrinkResources true in build.gradle to replace unused resources with tiny placeholders. Example:

android {
    ...
    buildTypes {
        release {
            shrinkResources true
        }
    }
}

Note that values/ resources are not removed by the compressor; you may need to manually delete them.

Language Resource Optimization : Limit packaged languages via resConfigs:

android {
    defaultConfig {
        resConfigs "zh", "zh-rCN"
    }
}

resources.arsc Optimization

Enable resource obfuscation (e.g., using AndResGuard).

Remove duplicate resources by comparing CRC‑32 checksums and redirecting them to a single entry.

Delete unused resources identified by the resource‑usage analyzer.

Summary

The presented techniques—Zip format tweaks, dex shrinking, R field inlining, image format selection, resource compression, language filtering, and duplicate‑resource removal—can collectively reduce APK size significantly. Combining these with a disciplined development approach and selective feature removal yields the most effective size reduction.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Androidimage compressionProGuardAPK size reduction
Meituan Technology Team
Written by

Meituan Technology Team

Over 10,000 engineers powering China’s leading lifestyle services e‑commerce platform. Supporting hundreds of millions of consumers, millions of merchants across 2,000+ industries. This is the public channel for the tech teams behind Meituan, Dianping, Meituan Waimai, Meituan Select, and related services.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.