您好,登錄后才能下訂單哦!
這幾天研究了一下阿里百川熱修復,簡單記一下集成流程。
以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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。