Https://github.com/AItsuki/HotFix
Issues
- Mac system cannot automatically pack patches due to path delimiter issues
- Unable to inject code after using Google Multidex sub-package (after opening multidex, the jar package save path changed)
- 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:
- Support confusion
- Automatically generate patch Packs
- 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
- 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.
- Running directly in debug mode or packaging verifies Hash.txt and mapping.txt, automatically generates a patch package, and signs the patch package.
- 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