| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

AndFix:阿里巴巴开源Android App线上问题修复工具

AndFix这个库为Android App提供了热修复的功能。它能够帮助Android开发人员在线修复App Bug。
Andfix是" And roid hot- fix "首字母缩写。

AndFix支持Android 2.3 至 6.0, arm 和 x86 架构, dalvik runtime 和 art runtime.

AndFix's patch is .apatch file.

Principle

The implementation principle of AndFix is method's body replace :

AndFix:阿里巴巴开源Android App线上问题修复工具

bug fix process:

AndFix:阿里巴巴开源Android App线上问题修复工具

Integration

How to get?

  1. directly add AndFix aar to your project as compile libraries.
  2. maven dependency:

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

    or gradle dependency:

    dependencies {      compile 'com.alipay.euler:andfix:0.3.0@aar'  }

How to use?

  1. initialize PatchManager:

    patchManager = new PatchManager(context);  patchManager.init(appversion);//current version 
  2. load patch. load patch as early as possible, generally, at the initialization phase of your app (such as application.oncreate()):

    patchManager.loadPatch();
  3. add patch. when new patch file has be downloaded,the patch will become effective immediately by add.

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

ProGuard

To ensure that these classes can be found after running an obfuscation and static analysis tool like ProGuard add the configuration below to your ProGuard configuration file.

  • native method

    com.euler.cloudfix.CloudFix

  • annotation

    com.euler.cloudfix.annotation.MethodReplace

    -keep class * extends java.lang.annotation.Annotation  -keepclasseswithmembernames class * {      native <methods>;  }

Developer Tool

The patch make tool is apkpatch.

How to get?

Apkpatch can be foundhere

How to use?

  • generate .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 files:
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.

Running sample

  1. import samples/AndFixDemo to your IDE, set AndFixDemo depend on AndFix(library project or aar).
  2. build project, save the package as 1.apk, and then install on device/emulator.
  3. modify com.euler.test.A, references com.euler.test.Fix.
  4. build project, save the package as 2.apk.
  5. use apkpatch to make a patch.
  6. rename the patch file to out.apatch, and then copy it onto sdcard.
  7. run 1.apk,view logcat.

API Documentation

The libraries javadoc can be found here


项目主页:
http://www.open-open.com/lib/view/home/1442330606790

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1442330606790.html
AndFix Android开发 移动开发