Android does not issue version can also fix the bug online? --andfix Frame

Source: Internet
Author: User

Geese are in droves, Eagles always fly aloof

Before you introduce a Alibaba framework dexposed framework, this framework is capable of dynamically doing some patches on the line. However, because of its performance and compatibility (art is not supported), many friends have decided to stop studying this framework.

Today, I'm going to introduce you to a Alibaba open source framework--andfix. Like dexposed, this framework is designed to be able to patch online. That is, after the bug is discovered, the tool library for local logic code is repaired with the online patch.

The principle is similar to dexposed, here we do not explain, if not clear children's shoes, you can see my other two article:
http://blog.csdn.net/yzzst/article/details/47954479
http://blog.csdn.net/yzzst/article/details/47659987

If you're going to ask me, why is the Alibaba internal team doing two of the same thing?
I can only answer that if you have worked in a big company, you should know that there is a kind of sorrow called--KPI.

Andfix's github address: Https://github.com/alibaba/AndFix

How do I use it?
The official documents translated by the author are as follows:

Andfix

Andfix is an online hot patch framework for Android apps. Using this framework, we are able to modify the bug in the app online without re-recurring version. Andfix is the abbreviation for "Android Hot-fix".

For now, Andfix supports Android version 2.3 to 6.0 and supports arm and X86 system architectures. Perfect support for Dalvik and art runtime.

Andfix patch files are files that end in. Apatch.

Andfix principle

The principle of andfix is very simple. is to replace the work with the replacement of the original method in the project:

While we are playing an online patch, we have the following steps logic:

Integrated Project use

Add Andfix AAR directly to the compilation dependency library in the project.

maven Dependencies :

<dependency>    <groupId>com.alipay.euler</groupId>    <artifactId>andfix</artifactId>    <version>0.3.0</version>    <type>aar</type></dependency>

or a gradle dependency :

dependencies {    compile‘com.alipay.euler:andfix:0.3.0@aar‘}
How to use

1. Initialize Patchmanager:

new PatchManager(context);patchManager.init(appversion);//current version

2. load a patch pack
The sooner you load the patch pack, the better, generally, we'll usually load the patch package in the OnCreate method in the custom application. That

patchManager.loadPatch();

3. Add a patch pack
The new patch package, after downloading, calls the Addpatch method to add patches. This patch will take effect immediately.

patchManager.addPatch(path);//path of the patch file that be downloaded
Proguard Obfuscation Settings

Make sure that some class files are not confused by Proguard when they are in use, and of course, the obfuscation configuration of Proguard is as follows:

    • Native method
com.euler.cloudfix.CloudFix
    • Annotation
class * extends java.lang.annotation.Annotationclass * {    native <methods>;}
Development Use Tools

Do not think that the patch is that we directly develop an APK, the production of patches is required to special tools. Here is a tool called Apkpatch, which is used to make andfix patches.

Address: Https://github.com/alibaba/AndFix/raw/master/tools/apkpatch.zip

How to use the tool

Generate the. apatch file

 usage: apkpatch -f <new> -t <old> -o <output> -k <keystore> -p <***> -a <alias> -e <***> -a,--alias <alias>     alias. -e,--epassword <***>   entry password. -f,--from <loc>        new Apk file path. -k,--keystore <loc>    keystore path. -n,--name <name>       patch name. -o,--out <dir>         output dir. -p,--kpassword <***>   keystore password. -t,--to <loc>          old Apk file path.

Merge. apatch file

 usage: apkpatch -m <apatch_path...> -k <keystore> -p <***> -a <alias> -e <***> -a,--alias <alias>     alias. -e,--epassword <***>   entry password. -k,--keystore <loc>    keystore path. -m,--merge <loc...>    path of .apatch files. -n,--name <name>       patch name. -o,--out <dir>         output dir. -p,--kpassword <***>   keystore password.
Run sample
    1. Import Samples/andfixdemo to your own IDE, set Andfixdemo dependent on Andfix (library project or AAR).
    2. Build project, save the compiled result to 1.apk, install the APK into the device.
    3. Modify COM.EULER.TEST.A, reference Com.euler.test.Fix.
    4. Build project, Save as 2.apk.
    5. Use the Apkpatch tool to make a patch.
    6. Rename the patch file to Out.apatch, and then copy the file to the SD card.
    7. Run 1.apk view Logcat.

/*
* @author Zhoushengtao (Zhou San)
* @since September 15, 2015 15:23:00
* @weixin stchou_zst
* @blog http://blog.csdn.net/yzzst
* @ Exchange Learning QQ Group: 341989536
* @ Private qq:445914891
/

Copyright NOTICE: Reprint please mark: Http://blog.csdn.net/yzzst. This article for Bo Master original article, without Bo Master permission not reproduced.

Android does not issue version can also fix the bug online? --andfix Frame

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.