Android Gradle Project Hotfix access to hot fix technology

Source: Internet
Author: User

Https://github.com/AItsuki/HotFix
Issues
    1. Mac system cannot automatically pack patches due to path delimiter issues
    2. Unable to inject code after using Google Multidex sub-package (after opening multidex, the jar package save path changed)
    3. Productflavors not supported at this stage

The above questions are free to change, recently busy other things, the company project is also ready to restructure. And this project is mainly science and learning hot patch technology, interested can solve the above problems on their own.

I. Introduction of Hotfix

A hot patch framework based on the Dex sub-package, currently only supports Gradle 1.5 or later with the following features:

    1. Support confusion
    2. Automatically generate patch Packs
    3. Signing verification when a patch pack is loaded

Project Demo

Second, the mode of use

First, there are two DSLs in build.gradle that need to be configured.

2.1 Fixmode
    • Fixmode is the configuration of running the project in debug mode, can control whether to use Javassist injection code, whether to automatically generate patches, the daily development of two set to False
    • Since the code is injected, the custom control will report a null pointer when preview is previewed (Antilazy.class cannot be found), so you need to turn debugon off to make it easier to preview.
2.2 Fixsignconfig

This is the configuration of the signature file of the package, need to be consistent with release signature packaging, otherwise load the patch will be verified failure, which is also for security purposes, to prevent malicious injection of code.

Storefile,storepassword,keyalias,keypassword corresponds to the following

Once the Build.gradle is configured, you only need to run the release signature package once, then modify the code, and run the debug package again to automatically generate the patch.

Third, the description
    1. The hash.txt is regenerated when the release signature is packaged, and Mapping.txt is generated if the confusion is turned on, and the automatically generated patch package is validated against this version.
    2. Running directly in debug mode or packaging verifies Hash.txt and mapping.txt, automatically generates a patch package, and signs the patch package.
    3. Copy the generated patch package to the SDcard root directory and restart the app for a hot fix.

It is important to note that if confusion is turned on in release packaging, it is also necessary to confuse debug turn-on when generating patches automatically, otherwise all classes of the entire project will be packaged as a patch package.

Debug open obfuscation is as follows

3.1 About Signature Verification

Only the APK with release output will be used for signature verification when the patch is loaded.

If the debug package is installed on your phone, the signature check will not be performed.

3.2 More about android6.0

The patch package cannot be loaded from SDcard because there is run-time permission handling after android6.0. Loading from SDcard is just for the convenience of testing and demonstration, in general it is recommended to be placed in a private directory.


Android Gradle Project Hotfix access to hot fix technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.