这几天研究了一下阿里百川热修复,简单记一下集成流程。
以AndroidStudio为例:
1.SDK下载及导入:
①下载地址:https://mhub.console.aliyun.com/?spm=5176.doc53239.2.1.5l5VVl#/download
②将下载的SDK文件放入libs文件夹
2.Gradle文件配置
①全局Gradle里添加
allprojects {
repositories {
jcenter()
maven {
url "http://maven.aliyun.com/nexus/content/repositories/releases"
}
}
}
②app的Gradle里添加
dependencies里添加compile 'com.aliyun.ams:alicloud-android-hotfix:3.0.2'
3.代码部分
①MyApplication继承Appliction,初始化热修复
public class MyApplication extends Application{
public interface MsgDisplayListener {
void handle(String msg);
}
public static MsgDisplayListener msgDisplayListener = null;
public static StringBuilder cacheMsg = new StringBuilder();
@Override
public void onCreate() {
super.onCreate();
initHotfix();
}
private void initHotfix() {
String appVersion;
try {
appVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
} catch (Exception e) {
appVersion = "1.0.0";
}
SophixManager.getInstance().setContext(this)
.setAppVersion(appVersion)
.setAesKey(null)
.setEnableDebug(true)
.setPatchLoadStatusStub(new PatchLoadStatusListener() {
@Override
public void onLoad(final int mode, final int code, final String info, final int handlePatchVersion) {
String msg = new StringBuilder("").append("Mode:").append(mode)
.append(" Code:").append(code)
.append(" Info:").append(info)
.append(" HandlePatchVersion:").append(handlePatchVersion).toString();
if (msgDisplayListener != null) {
msgDisplayListener.handle(msg);
} else {
cacheMsg.append("\n").append(msg);
}
}
}).initialize();
}
}
②执行Query方法去服务器拉取最新补丁
SophixManager.getInstance().queryAndLoadNewPatch();
4.下载打包工具SophixPatchTool
①下载地址:http://ams-hotfix-repo.oss-cn-shanghai.aliyuncs.com/SophixPatchTool_windows.zip?spm=5176.doc53287.2.35.fxB5kE&file=SophixPatchTool_windows.zip
②AndroidStudio生成有BUG的1.0.0的apk安装包和修复BUG的1.0.1的apk安装包,用SophixPatchTool进行差别检测,生成sophix-patch.jar补丁包
5.后台操作
①打开https://hotfix.console.aliyun.com/?spm=5176.2020520107.1001.179.3227adabSXRF6n#/list
找到你的APP,打开管理,创建一个版本号为1.0.0的版本(必须是1.0.0)②然后打开1.0.0版本的查看详情,上传之前生成的sophix-patch.jar补丁包,发布补丁包
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。