Skip to content

Complete Integration Document for Android App Differential Update (Based on UpgradeLink + DiffUpdater)

I. Core Concept of Differential Update

Differential update (also known as incremental update) is an efficient app update solution. Its core logic is: when updating an app, only download the differential part (usually called a "patch package") between the current version and the target version, instead of the complete target version installation package (APK package).

Compared with traditional full update, the core advantages of differential update lie in:

  1. Reduced data consumption: The size of the patch package is only 10%-30% of the complete APK (depending on the version difference), significantly reducing the network data cost for users during updates;
  2. Improved update efficiency: Smaller patch packages download faster, especially shortening the update waiting time in weak network environments;
  3. Reduced server pressure: Servers only need to distribute small-sized patch packages, reducing bandwidth usage and storage overhead.

Its underlying principle is to compare the binary data of the old and new APK files through specific algorithms (such as BSDiff, HDiffPatch, etc.), extract the differential content to generate a patch package. After the client downloads the patch package, it merges it with the local old APK to generate a complete target version APK, and finally completes the installation and update.

II. Introduction to Core Systems

UpgradeLink is the backend service core of the differential update solution, focusing on providing basic capabilities and configuration support required for the entire update process, eliminating the need for developers to pay attention to the implementation details of backend logic.

Core Functions:

  1. Version Management: Supports maintaining historical version and target version information of the app, and records the storage addresses of APK packages and patch packages for each version;
  2. Update Rule Configuration: Allows setting rules such as mandatory update/optional update, channel-specific update, and version range restrictions;
  3. Patch Package Generation and Storage: Interfaces with differential algorithms to automatically generate and store patch packages based on old and new version APKs, providing stable download links;
  4. Update Status Verification: Receives version query requests from clients and returns core data such as target version information, patch package address, and update rules;
  5. Compatibility Support: Adapts to devices with different Android system versions and architectures to ensure the versatility of the update process.

Core Value:

Provides "one-stop" update decision support for clients. Developers do not need to build an independent update backend; they can quickly obtain all configuration information required for updates by calling its API, focusing on front-end update interaction and logic processing.

(II) DiffUpdater: Android Differential Update SDK

DiffUpdater is a lightweight differential update development toolkit designed specifically for Android apps. It is responsible for completing specific operations such as patch package download, merging, and installation on the client side, featuring ease of use and customization.

Core Functions:

  1. Patch Package Processing: Supports mainstream differential algorithms (specifiable via the patchAlgo parameter), enabling efficient merging of local old APKs with downloaded patch packages to generate complete target version APKs;
  2. Download Management: Built-in patch package download capability, supporting resuming from breakpoints, download progress monitoring, and automatic retry after download failure;
  3. Installation Adaptation: Automatically handles Android system installation permission application, APK file verification (MD5/SHA), silent installation (requires system permissions), or manual installation guidance;
  4. Status Callback: Returns key events such as download progress, merge status, and installation results to the app, facilitating front-end UI display of update status;
  5. Customization Support: Supports custom download paths, update pop-up styles, failure handling logic, etc., to adapt to the interaction needs of different apps.

Core Advantages:

  • Lightweight and dependency-free: Small SDK size, no additional redundant dependencies, avoiding increasing the app package size;
  • Stable and efficient: Optimized merging algorithm, low memory usage, fast merging speed, and compatibility with low-configuration devices;
  • Easy integration: Provides concise API interfaces, allowing developers to quickly integrate without paying attention to the underlying implementation of differential merging.
  1. Front-end triggers update check: After the app starts or the user manually triggers an update, the front-end UI displays the update query status. By specifying the patchAlgo parameter (selecting a differential algorithm), it calls UpgradeLink's API interface and passes in information such as the current app version number and channel number;
  2. Backend returns update configuration: UpgradeLink verifies the update rules based on the passed parameters and returns the result (if differential update is supported, it returns the patch package address, target version number, verification information, etc.; if not supported, it returns the full APK address and follows the full update process);
  3. Client processes the patch package: DiffUpdater receives the patch package address returned by UpgradeLink, initiates the patch package download (with progress monitoring), and verifies the file integrity after the download is complete;
  4. Differential merging to generate new APK: DiffUpdater calls the specified differential algorithm to merge the local old version APK with the downloaded patch package, generates a complete target version APK, and performs MD5 verification to ensure the file is correct;
  5. Trigger installation and update: DiffUpdater automatically applies for installation permissions, guides the user to complete the installation of the target version APK, and the app automatically starts the new version after installation;
  6. Exception handling: If the download fails, merge fails, or installation fails, the system automatically calls back the failure status, and users can choose to retry the operation or switch to the full update process.

IV. Core Summary

  • UpgradeLink is responsible for "backend support": Provides update rules, version information, and patch package resources, solving the decision-making problem of "what to update and how to update";
  • DiffUpdater is responsible for "front-end execution": Completes patch package download, merging, and installation, solving the execution problem of "how to implement the update";
  • The two work together to form a complete differential update solution of "backend configuration - front-end execution", helping developers implement efficient and data-saving app update functions at the lowest cost, and improving user experience and development efficiency.

toolsetlink@163.com