Design and Implementation of Youzan's Mobile Hotfix Platform
Youzan's mobile hot‑fix platform automates building, storing, and delivering patch packages via a standardized hot‑fix branch, integrates local verification, supports full, gray, and conditional releases with approval workflow, and provides real‑time statistics and rollback, enabling rapid, low‑risk bug fixes without republishing the entire app.
This article presents the design, implementation, and operational workflow of a hot‑fix platform built for Youzan's mobile applications. It starts with the background: rapid app iteration and frequent releases make it necessary to fix production issues without republishing the whole app. Hot‑fixes provide real‑time, user‑transparent bug remediation, reducing risk and cost.
The platform addresses several practical problems, such as preserving baseline APKs and mapping files, managing hot‑fix branches, building and storing patch packages, local verification, release approval, and statistical monitoring.
Platform definition lists the required capabilities: saving build artifacts, defining a standard hot‑fix branch naming scheme, supporting patch construction and storage, enabling easy local validation, handling permission approval, supporting full, gray, and conditional releases, providing status query and data statistics, and allowing historical hot‑fix code inspection.
Build artifact storage uses Youzan's internal Mobile Build (MBD) platform. The MBD pipeline runs on a GitLabRunner (implemented in Go) and uploads APKs, mapping files, and other artifacts to a CDN. A sample YAML build script is shown:
build:Git API
artifacts:
untracked: false
name: "out"
preview_pattern: "app-full-release.apk"
cdn_path: "xxxxxxxx"
paths:
- app/build/bakApk
- app/build/outputs/apk/
- app/build/outputs/mapping/full/release/
script:
- env
- ./gradlew clean assembleFullRelease -PTINKER_ID=$CI_BUILD_ID -PBAK_PATH=$CI_PROJECT_DIR/app/build/bakApk -Paar=$JOB_COMPONENT_DEPENDENCIES -PMBD_RELEASE=$JOB_BUILD_RELEASE -PMBD_TEST_VERSION=$JOB_COMPONENT_VERSION -PMBD_BRANCH_NAME=$CI_COMMIT_REF_NAME --no-daemonHot‑fix branch convention uses a fixed branch name per release, e.g., hotfix/2.3.5-mbd . Developers create a temporary bug‑fix branch from this hot‑fix branch, fix the issue, and build a patch.
Patch construction is also performed on MBD. The patch‑building YAML script is:
patch:
artifacts:
untracked: false
name: "patch"
preview_pattern: "patch_signed.apk"
paths:
- app/build/outputs/apk/full/tinkerPatch/full/release/patch_signed_7zip.apk
- app/build/outputs/apk/full/tinkerPatch/full/release/patch_signed.apk
script:
- env
- pwd
- mv app/build/bakApk base/
- ls base/
- ./gradlew clean tinkerPatchFullRelease -Paar=$JOB_COMPONENT_DEPENDENCIES --no-daemon -POLD_BUILD_FLAVOR=$CI_PROJECT_DIR/base
- rm -rf baseVerification uses Tinker’s API to load a local patch:
TinkerInstaller.onReceiveUpgradePatch(context,
localPatchPath
);The verification process is integrated into the Youzan Mobile Assistant app, which scans a QR code containing patch metadata (MD5, CDN URL, baseline version, package name) and performs automatic download and installation.
Release strategies include:
Full release – the patch is delivered to all users of the target version.
Gray release – a percentage‑based rollout using a hash of the device identifier to decide distribution.
Conditional release – patches are delivered only when a DSL condition (e.g., userId == 10023451 && roleType == 1 ) evaluates to true.
Approval workflow requires a team lead (TL) to review the hot‑fix code and approve the release on the Apub platform. The system automatically creates a merge request (MR) linking the bug‑fix branch to the release branch, and the patch can be published only after the MR is merged.
Additional features include real‑time statistics (number of devices patched, error counts), device‑level hot‑fix status query, and a code‑rollback mechanism that links to the corresponding GitLab MR for historical inspection.
The article also outlines the overall architecture diagram (MBD, Apub, CDN, Tinker, Mobile Assistant) and provides a step‑by‑step Android hot‑fix workflow, followed by a brief iOS hot‑fix process, which is simpler because it does not involve baseline APK handling.
In conclusion, the platform delivers a reliable, efficient, and secure hot‑fix solution that can be reused across business lines, reducing duplicated effort and improving production stability.
Youzan Coder
Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.