一、AndFix的基本介绍
=============
官方介绍:alibaba/AndFix
以后学习任何新技术,优先去官网查看文档,然后再考虑去看博客文章。
二、AndFix执行流程及核心原理
=================
见官方介绍
三、使用AndFix完成线上bug修复
===================
1、集成阶段
a、gradle中添加AndFix依赖
compile ‘com.alipay.euler:andfix:0.5.0@aar’
b、在代码中完成AndFix的初始化
封装AndFixPatchManager
/**
-
Created by GuanSong
-
Description:管理AndFix所有的api
-
on 2019/8/2.
*/
public class AndFixPatchManager {
private static AndFixPatchManager mInstance = null;
private static PatchManager mPatchManager = null;
private AndFixPatchManager() {
}
public static AndFixPatchManager getInstance() {
if (mInstance == null) {
synchronized (AndFixPatchManager.class) {
if (mInstance == null) {
mInstance = new AndFixPatchManager();
}
}
}
return mInstance;
}
//初始化AndFix方法
public void initPatch(Context context) {
mPatchManager = new PatchManager(context);
mPatchManager.init(Utils.getVersionName(context));
mPatchManager.loadPatch();
}
//加载我们的patch文件
public void addPatch(String path) {
try {
if (mPatchManager != null) {
mPatchManager.addPatch(path);
}
} catch (IOException e) {
e.printStackTrace();
}