-
Notifications
You must be signed in to change notification settings - Fork 307
热更新so,怎样判断是否成功
rocky edited this page Nov 8, 2019
·
1 revision
1.参考热更新DEMO,里面提供了native 代码编辑
2.查看logcat日志,过滤tag "crashreport",看下是否有收到bugly后台配置的热更新策略,对应关键词是"onUpgradeReceived"
2019-11-08 22:17:13.527 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Upload] Upload to http://android.bugly.qq.com/rqd/async?aid=37325dea-529c-4b4b-bf0b-7b8a2e1b3fc6 with cmd 804 (pid=30826 | tid=30848).
2019-11-08 22:17:13.528 30826-30848/com.tencent.bugly.hotfix D/CrashReport: request: http://android.bugly.qq.com/rqd/async?aid=37325dea-529c-4b4b-bf0b-7b8a2e1b3fc6, send: 738 (pid=30826 | tid=30848)
2019-11-08 22:17:13.581 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Upload] Bugly version from headers is: bugly/1.0
2019-11-08 22:17:13.582 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Upload] Status from server is 0 (pid=30826 | tid=30848).
2019-11-08 22:17:13.582 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Upload] Received 346 bytes
2019-11-08 22:17:13.590 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Util] Unzip 330 bytes data with type Gzip
2019-11-08 22:17:13.593 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Upload] Response cmd is: 804, length of sBuffer is: 282
2019-11-08 22:17:13.593 30826-30848/com.tencent.bugly.hotfix I/CrashReport: [Upload] Success: 804
2019-11-08 22:17:13.596 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [UploadManager] Local network consume: 1 KB
2019-11-08 22:17:13.599 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Database] deleted t_lr data 1
2019-11-08 22:17:13.601 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Database] insert t_lr success.
2019-11-08 22:17:13.601 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [UploadManager] Network total consume: 2 KB
2019-11-08 22:17:13.602 30826-30849/com.tencent.bugly.hotfix D/CrashReport: [Util] Try to lock file:local_crash_lock (pid=30826 | tid=30849)
2019-11-08 22:17:13.602 30826-30848/com.tencent.bugly.hotfix I/CrashReport: upload succ:[804] [sended 738] [recevied 346]
2019-11-08 22:17:13.606 30826-30849/com.tencent.bugly.hotfix D/CrashReport: [Util] Successfully locked file: local_crash_lock (pid=30826 | tid=30849)
2019-11-08 22:17:13.609 30826-30849/com.tencent.bugly.hotfix D/CrashReport: Size of crash list loaded from DB: 0
2019-11-08 22:17:13.610 30826-30849/com.tencent.bugly.hotfix D/CrashReport: [Util] Try to unlock file: local_crash_lock (pid=30826 | tid=30849)
2019-11-08 22:17:13.610 30826-30849/com.tencent.bugly.hotfix D/CrashReport: [Util] Successfully unlocked file: local_crash_lock (pid=30826 | tid=30849)
2019-11-08 22:17:13.614 30826-30848/com.tencent.bugly.hotfix D/CrashReport: [Database] insert st_1002 success.
2019-11-08 22:17:13.616 30826-30848/com.tencent.bugly.hotfix I/CrashReport: onUpgradeReceived: title:
newFeature:
publishTime: 0
publishType: 0
appBasicInfo: {
appId: e0b1ba785f
platformId: 1
versionCode: 0
versionName: null
buildNo: 0
iconUrl: null
apkId: 0
channelId: null
md5: 4575dd53dbd9804be3cf09525d02df48525bb5ec
sdkVer:
bundleId: null
}
apkBaseInfo: {
apkMd5: 4575dd53dbd9804be3cf09525d02df48525bb5ec
apkUrl: https://s.beta.gtimg.com/rdmimg/hot_patch/e0b1ba785f/8ad9fca8-b376-45cc-bec5-c7725b7035f8.zip
manifestMd5:
fileSize: 16467
signatureMd5:
}
updateStrategy: 0
popTimes: 0
popInterval: 0
diffApkInfo: {
null}
netType: null
reserved: 1, {
(
H2
1
)
}
strategyId: 96c65a64-5987-4646-a6ae-412356de5668
status: 1
updateTime: 1573221673000
updateType: 3
[type: 3]
2019-11-08 22:17:13.619 30826-30848/com.tencent.bugly.hotfix W/CrashReport: task start com.tencent.bugly.proguard.t
2019-11-08 22:17:13.855 30826-30893/com.tencent.bugly.hotfix D/CrashReport: [Database] insert dl_1002 success.
2019-11-08 22:17:13.944 30826-30826/com.tencent.bugly.hotfix I/CrashReport: patch download success !!!
2019-11-08 22:17:13.950 30826-30826/com.tencent.bugly.hotfix D/CrashReport: copy /data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/8ad9fca8-b376-45cc-bec5-c7725b7035f8.zip to /data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/tmpPatch.apk success!
2019-11-08 22:17:13.950 30826-30826/com.tencent.bugly.hotfix D/CrashReport: delete temp file
2019-11-08 22:17:14.515 30826-30826/com.tencent.bugly.hotfix I/CrashReport: Tinker patch success, result:
PatchResult:
isSuccess:true
rawPatchFilePath:/data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/tmpPatch.apk
costTime:131
patchVersion:46ec9cf594ca2ffb98c6a478f80e43b8
- 如果发现接收到热更新策略,过滤Logcat日志,tag为"tinker",查看tinker打补丁的过程和结果
2019-11-08 22:17:10.247 30826-30826/? D/Tinker.TinkerLoader: tryLoad test test
2019-11-08 22:17:10.250 30826-30826/? W/Tinker.TinkerLoader: tryLoadPatchFiles:patch dir not exist:/data/user/0/com.tencent.bugly.hotfix/tinker
2019-11-08 22:17:10.251 30826-30826/? D/Tinker.DefaultAppLike: onBaseContextAttached:
2019-11-08 22:17:10.261 30826-30826/? I/Tinker.TinkerPatchListener: application maxMemory:384
2019-11-08 22:17:10.263 30826-30826/? W/Tinker.Tinker: tinker patch directory: /data/user/0/com.tencent.bugly.hotfix/tinker
2019-11-08 22:17:10.265 30826-30826/? I/Tinker.Tinker: try to install tinker, isEnable: true, version: 1.9.14.3
2019-11-08 22:17:10.266 30826-30826/? I/Tinker.TinkerLoadResult: parseTinkerResult loadCode:-2, process name:com.tencent.bugly.hotfix, main process:true, systemOTA:false, fingerPrint:HUAWEI/MHA-AL00/HWMHA:9/HUAWEIMHA-AL00/9.1.0.200C00:user/release-keys, oatDir:null, useInterpretMode:false
2019-11-08 22:17:10.266 30826-30826/? W/Tinker.TinkerLoadResult: can't find patch file, is ok, just return
2019-11-08 22:17:10.266 30826-30826/? I/Tinker.DefaultLoadReporter: patch loadReporter onLoadResult: patch load result, path:/data/user/0/com.tencent.bugly.hotfix/tinker, code: -2, cost: 3ms
2019-11-08 22:17:10.267 30826-30826/? W/Tinker.Tinker: tinker load fail!
2019-11-08 22:17:10.273 30826-30826/? I/Tinker.ComponentHotplug: method install() is not invoked, ignore ensuring operations.
2019-11-08 22:17:10.273 30826-30826/? D/Tinker.DefaultAppLike: onCreate
2019-11-08 22:17:10.313 30826-30826/? I/CrashReport: backup java handler: com.tencent.bugly.beta.tinker.TinkerUncaughtExceptionHandler@247d3d3
2019-11-08 22:17:10.366 30826-30826/? W/CrashReport: [patch] tinker new id is null ,so patch version is invalid
2019-11-08 22:17:10.366 30826-30826/? I/CrashReport: TINKER_ID:2.0.3_1108-21-59-19
2019-11-08 22:17:10.367 30826-30826/? I/CrashReport: NEW_TINKER_ID:
2019-11-08 22:17:10.749 30826-30826/? W/Tinker.UpgradePatchRetry: onPatchRetryLoad retry info not exist, just return
2019-11-08 22:17:13.450 30826-30850/com.tencent.bugly.hotfix D/CrashReport: app version is: [2.0.3], [deviceId:null|null|db1b5e9e1af8c837], channel: [null], base tinkerId:[2.0.3_1108-21-59-19], patch tinkerId:[], patch version:[]
2019-11-08 22:17:13.958 30826-30826/com.tencent.bugly.hotfix D/Tinker.TinkerManager: onDownloadSuccess.
2019-11-08 22:17:13.969 30826-30826/com.tencent.bugly.hotfix D/Tinker.TinkerManager: check if has new patch.
2019-11-08 22:17:13.990 30826-30826/com.tencent.bugly.hotfix D/Tinker.TinkerManager: has new patch.
2019-11-08 22:17:13.991 30826-30826/com.tencent.bugly.hotfix D/Tinker.TinkerManager: starting patch.
2019-11-08 22:17:13.992 30826-30826/com.tencent.bugly.hotfix I/Tinker.TinkerPatchListener: receive a patch file: /data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/tmpPatch.apk, file size:16467
2019-11-08 22:17:13.998 30826-30826/com.tencent.bugly.hotfix W/Tinker.PatchInfo: read property failed, e:java.io.FileNotFoundException: /data/user/0/com.tencent.bugly.hotfix/tinker/patch.info (No such file or directory)
2019-11-08 22:17:13.998 30826-30826/com.tencent.bugly.hotfix W/Tinker.PatchInfo: read property failed, e:java.io.FileNotFoundException: /data/user/0/com.tencent.bugly.hotfix/tinker/patch.info (No such file or directory)
2019-11-08 22:17:13.999 30826-30826/com.tencent.bugly.hotfix W/Tinker.UpgradePatchRetry: onPatchListenerCheck retry file is not exist, just return
2019-11-08 22:17:14.001 30826-30826/com.tencent.bugly.hotfix I/Tinker.TinkerPatchListener: get platform:null
2019-11-08 22:17:14.006 30826-30826/com.tencent.bugly.hotfix I/Tinker.TinkerPatchService: run patch service...
2019-11-08 22:17:14.513 30826-30935/com.tencent.bugly.hotfix I/Tinker.TinkerResultService: TinkerResultService receive result:
PatchResult:
isSuccess:true
rawPatchFilePath:/data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/tmpPatch.apk
costTime:131
patchVersion:46ec9cf594ca2ffb98c6a478f80e43b8
2019-11-08 22:17:14.514 30826-30935/com.tencent.bugly.hotfix W/Tinker.DefaultTinkerResultService: deleteRawPatchFile rawFile path: /data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/tmpPatch.apk
2019-11-08 22:17:14.514 30826-30935/com.tencent.bugly.hotfix I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/tmpPatch.apk
2019-11-08 22:17:14.514 30826-30935/com.tencent.bugly.hotfix I/Tinker.TinkerResultService: tinker wait screen to restart process
2019-11-08 22:17:14.515 30826-30826/com.tencent.bugly.hotfix I/CrashReport: Tinker patch success, result:
PatchResult:
isSuccess:true
rawPatchFilePath:/data/user/0/com.tencent.bugly.hotfix/app_tmpPatch/tmpPatch.apk
costTime:131
patchVersion:46ec9cf594ca2ffb98c6a478f80e43b8
-
如果打补丁失败:isSuccess:false,则停止,需要请求tinker官方寻求指导
-
如果打补丁成功,重启app,检测so是否修复。首先查看logcat日志,过滤"loadLibraryFromTinker",这个关键词是检测app重启后加载so的来源,是否是由tinker加载补丁包里的so,如果没有这行日志说明没有成功加载补丁so。如果有这个日志,说明本次启动加载了补丁包里的so。
-
有时候发现以上均执行成功,so还是没有更新成功。可能是app重启后除了tinker加载了补丁的so,app代码还有其他地方调用System.loadLibrary加载了app原来的so。可以通过制造一个native 崩溃,查看bugly 日志(bugly会打印崩溃时的内存镜像),搜索so名字,看是否存在重名的so在内存中。如果存在说明app启动过程加载了两份so,需要去掉重复的一处调用。