Mobile Development 14 min read

APK Size Optimization Techniques for Game Center Application

Ke Jie explains why reducing the Game Center APK—by eliminating alpha‑PNG images, unused code and resources, limiting language and density assets, disabling v1 signing, compressing images, loading native libraries on demand, shipping only 64‑bit binaries, enabling code/resource shrinking and R‑file inlining—cut size by about 31% (≈20 MB), boosting download conversion and launch performance.

vivo Internet Technology
vivo Internet Technology
vivo Internet Technology
APK Size Optimization Techniques for Game Center Application

This article, authored by Ke Jie from the Vivo Internet Front‑End Team, explains the necessity of Android APK size optimization and presents practical measures applied to the Game Center app.

1. Necessity of Size Optimization – Larger APKs lead to lower download conversion rates. Google reported that each 6 MB increase in APK size reduces conversion by about 1%.

APK size reduction of 10 MB can noticeably improve conversion in various regions.

2. Game Center APK Composition

The APK contains directories such as META-INF/ , assets/ , res/ , lib/ , the resources.arsc index, classes.dex , and AndroidManifest.xml . The largest contributors to size are lib , res , assets , and resources .

3. Size‑Detection Tool

Matrix‑ApkChecker, part of the Matrix system, analyses APKs against predefined rules (resource obfuscation, PNG alpha channels, uncompressed files, redundant resources, etc.) and generates detailed reports.

Tool reference: https://github.com/Tencent/matrix/wiki/Matrix-Android-ApkChecker

4. Optimization Measures

4.1 Remove large PNGs with Alpha channel – Replace such PNGs with JPG or WebP to save space.

4.2 Code reduction – Delete unused business scenarios, resources, and classes, shrinking res and dex sections.

4.3 Minimal resource configuration – Keep only needed language resources, e.g., add in build.gradle :

resConfigs "zh-rCN", "zh-rTW", "zh-rHK"

4.4 Config‑resource optimization – Prefer xxhdpi and night-xxhdpi resources, removing unused density folders.

defaultConfig {
resConfigs isNotBaselineApk ? "" : ["xxhdpi", "night-xxhdpi"]
}

4.5 Remove v1 signing for Android 7+ – Disabling v1 signing saves ~600 KB.

signingConfigs {
gameConfig {
if (isNotBaselineApk) {
print("v1SigningEnabled true")
v1SigningEnabled true
} else {
print("v1SigningEnabled false")
v1SigningEnabled false
}
v2SigningEnabled true
}
}

4.6 Animation resource optimization – Replace heavy GIF/Lottie/SVG assets with PAG files (PAG is ~0.5× size of Lottie, ~0.2× of SVG). Example: a 701 KB GIF reduced to 67 KB PAG.

Reference: https://github.com/Tencent/libpag/blob/main/README.zh_CN.md

4.7 Compile‑time image compression – Insert WebP compression between mergeRes and processRes using cwebp . Tools such as Didi’s booster-task-compression-cwebp can be used.

4.8 Dynamic loading of native libraries – Load large .so files on demand. Example loading code:

System.loadLibrary(library);

Use ReLinker to reduce UnsatisfiedLinkError :

ReLinker.loadLibrary(context, "mylibrary")

Reference: https://github.com/KeepSafe/ReLinker

4.9 Ship only 64‑bit .so files – Since modern devices are arm64‑v8a, configure abiFilters accordingly.

ndk {
if ("64" == localMultilib) {
abiFilters "arm64-v8a"
} else if ("32" == localMultilib) {
abiFilters "armeabi"
} else {
abiFilters "armeabi", "arm64-v8a"
}
}

4.10 Enable code shrinking and resource shrinking – Set minifyEnabled true and shrinkResources true in release build type, and configure ProGuard rules.

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

4.11 R‑file inlining – Convert library module resource IDs to constants so that module‑level R files can be removed, reducing APK size. Open‑source solutions include Didi’s Booster and ByteDance’s ByteX.

References:

Booster R‑file inlining guide

ByteX R‑file inlining plugin

5. Optimization Results

The applied measures reduced the APK size by about 31% (≈20 MB), which can improve conversion rates by roughly 3% and increase launch speed by ~2.2%.

6. Conclusion

Before optimizing, analyze module size distribution and target the biggest contributors (e.g., lib , res , assets , resources ). Long‑term gains come from animation format migration, dynamic .so loading, and compile‑time image compression. Simple configurations such as resource minimization and R‑file inlining yield noticeable reductions. Future work includes further dex size reduction.

Androiddynamic loadingwebpProGuardAPK optimizationapp size reductionMatrix ApkChecker
vivo Internet Technology
Written by

vivo Internet Technology

Sharing practical vivo Internet technology insights and salon events, plus the latest industry news and hot conferences.

0 followers
Reader feedback

How this landed with the community

login 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.