Game Development 17 min read

Multi-Channel Packaging for Android Game Distribution: Architecture, Implementation, and Optimization

The article presents a comprehensive approach to Android game multi‑channel packaging, combining independent SDK modules with a unified proxy layer and an apktool‑based merge of manifests, resources, and smali code, automated through scripted Jenkins pipelines, which resolves dex limits, resource conflicts, and cuts packaging time from over an hour to roughly twenty minutes.

Bilibili Tech
Bilibili Tech
Bilibili Tech
Multi-Channel Packaging for Android Game Distribution: Architecture, Implementation, and Optimization

This article introduces the challenges of multi‑channel packaging for Android games, where a single APK must be customized for dozens of distribution channels such as Huawei, Xiaomi, Vivo, and Oppo. Traditional channel‑specific build configurations (flavors, Gradle scripts) are insufficient when only the compiled APK is available.

The proposed solution consists of two main parts: channel integration and packaging integration. Channel integration is achieved by encapsulating each channel SDK in an independent APK module and exposing a unified proxy layer that the game calls. This proxy abstracts channel‑specific APIs (login, payment, authentication) so the game remains unaware of underlying channel changes.

Packaging integration uses apktool to decompile the game’s mother‑package APK and a demo APK that contains the channel SDK. After decompilation, the proxy classes from the demo are merged into the mother‑package, and resources, assets, libraries, and manifest entries are combined. The process includes:

Merging AndroidManifest.xml with channel‑specific and game‑specific logic, and updating package‑related nodes.

Combining assets and lib directories, handling CPU‑specific native libraries.

Merging resource folders (anim, drawable, layout, etc.) and carefully merging values XML to avoid ID conflicts.

Replacing smali files for the proxy layer, and handling the 64K method limit by splitting classes into additional smali folders when necessary.

Automation is achieved through scripted steps:

Decompile both the mother‑package and channel demo APKs using apktool d .

Merge manifests, assets, libs, resources, and smali files according to the rules above.

Recompile the merged project with apktool b .

Sign the resulting APK with a signing tool.

To improve reliability across different development environments, the script is executed in a Jenkins CI pipeline, and a dedicated packaging platform (UO) is built to allow non‑technical users to trigger channel builds.

The article also shares practical pitfalls and solutions, such as handling dex method count overflow (multi‑dex), adjusting the order of obfuscation (protect) steps, managing R class and resource ID conflicts, and resolving provider/permission authority collisions by using placeholders and replace directives during manifest merging.

Finally, a performance comparison shows that the platform reduces the number of file transfers and manual interventions, cutting the total packaging time for a game with 8‑10 channels from over an hour to around 20 minutes, even when including an obfuscation step.

AndroidAutomationSDK integrationAPK ToolGame PackagingJenkinsMulti-Channel
Bilibili Tech
Written by

Bilibili Tech

Provides introductions and tutorials on Bilibili-related technologies.

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.