1.快速集成
1.成為開(kāi)發(fā)者,并創(chuàng)建一個(gè)應(yīng)用凭迹,申請(qǐng)使用熱更新(申請(qǐng)需要寫(xiě)理由,審核時(shí)間為4小時(shí)以內(nèi))
2.下載需要的資料
http://baichuan.taobao.com/docs/doc.htm?spm=a3c0d.7629140.0.0.D8AbfB&treeId=234&articleId=105517&docType=1
里面有BCFixPatchTools-1.2.0.jar,這個(gè)打補(bǔ)丁的時(shí)候會(huì)使用到
3.添加maven倉(cāng)庫(kù)地址:
repositories {
maven {
url"http://repo.baichuan-android.taobao.com/content/groups/public/"
}
}
4.添加gradle坐標(biāo)版本依賴:
dependencies {
compile'com.alibaba.sdk.android.plugins:alisdk-hotfix:1.3.3'
compile'com.alibaba.sdk.android.plugins.jar:alisdk-utdid:0.0.1'
}
5.權(quán)限說(shuō)明
6.節(jié)點(diǎn)配置
7.混淆配置
-keepclass*extendsjava.lang.annotation.Annotation
-keepclasseswithmembernamesclass* {
native;
}
-keepclasscom.alipay.euler.andfix.**{
*;
}
-keepclasscom.taobao.hotfix.aidl.**{*;}
-keepclasscom.ta.utdid2.device.**{*;}
-keepclasscom.taobao.hotfix.HotFixManager{
public*;
}
8.application初始化,appVersion必須和后臺(tái)配置的一樣
2.生成patch補(bǔ)丁
1. 把BCFixPatchTools-1.2.0.jar放入該目錄下
2. 新建一個(gè)patch_out文件夾作為最后補(bǔ)丁輸出目錄
3. 把原apk和修復(fù)后的apk也放置到該目錄中, 打包命令參考(debug: `./gradlew clean assembleDebug` release:`./gradlew clean assembleRelease`), ps:請(qǐng)勿直接使用AS即時(shí)編譯Instance Run出的apk產(chǎn)物進(jìn)行打補(bǔ)丁操作.
4. hotfix_demo目錄下執(zhí)行以下命令
java -jar E:\HotFix\puth\BCFixPatchTools-1.2.0.jar -cmd patch -src_apk E:\HotFix\puth\app-debug-old.apk -fixed_apk E:\HotFix\puth\app-debug-new.apk -wp E:\HotFix\puth\output
-cmd: 值為patch: 打補(bǔ)丁命令 值為help: 查看使用說(shuō)明
-src_apk:填寫(xiě)本地的原始APK(有問(wèn)題的APK)的絕對(duì)路徑,如果文件找不到會(huì)報(bào)錯(cuò), 必選
-fixed_apk:已經(jīng)修復(fù)過(guò)該問(wèn)題APK的絕對(duì)路徑, 必選
-wp:輸出patch的絕對(duì)路徑, 必選
-sign_file_url:本地的簽名文件的絕對(duì)路徑,不輸入或者不正確則不做簽名, 可選
-sign_file_pass: 證書(shū)文件的密碼
-sign_alias: 證書(shū)的別名
-sign_alias_pass: 證書(shū)別名的密碼
如果不輸入-sign_**相關(guān)的簽名參數(shù), 那么hotfix-working目錄下生成未簽名的baichuan-hotfix-patch.jar補(bǔ)丁包, 如果輸入了簽名相關(guān)參數(shù), 那么hotfix-working目錄下會(huì)生成baichuan-hotfix-patch-unsigned.jar(未簽名補(bǔ)丁包)和baichuan-hotfix-patch.jar(簽名補(bǔ)丁包), 如果沒(méi)有baichuan-hotfix-patch.jar(簽名補(bǔ)丁包)則表示簽名失敗.
filterClassFilePath:本地的白名單類(lèi)列表文件的絕對(duì)路徑喜命,放進(jìn)去的類(lèi)不會(huì)再計(jì)算patch,可選
filterClassFilePath參數(shù)的使用參考Demo工程下README.md文件的說(shuō)明, 同時(shí)該文件的格式:每行一個(gè)類(lèi)名, 必須包含包名前綴, 暫時(shí)不提供整包過(guò)濾
PatchLoadStatusListener接口
該接口需要自行實(shí)現(xiàn)并傳入initialize方法中, 補(bǔ)丁加載狀態(tài)會(huì)回調(diào)給該接口, 參數(shù)說(shuō)明如下:
mode: 補(bǔ)丁模式, 0:正常請(qǐng)求模式 1:掃碼模式 2:本地補(bǔ)丁模式
code: 補(bǔ)丁加載狀態(tài)碼, 詳情查看PatchStatusCode類(lèi)說(shuō)明
info: 補(bǔ)丁加載詳細(xì)說(shuō)明, 詳情查看PatchStatusCode類(lèi)說(shuō)明
handlePatchVersion: 當(dāng)前處理的補(bǔ)丁版本號(hào), 0:無(wú) -1:本地補(bǔ)丁 其它:后臺(tái)補(bǔ)丁
github源碼:https://github.com/LostDeer/HotFix