2023年11月29日发(作者:)
热修复框架-Tinker安装流程分析
代码tinker 1.9.14.7
TinkerApplication初始化完成之后,接着会在继承DefaultApplicationLike的⼦类中进⾏Tinker初始化:
@Override
public void onBaseContextAttached(Context base) {
ContextAttached(base);
Log.d(TAG, "HotFixApplicationLike onBaseContextAttached");
l(base);//使应⽤⽀持分包
LoadReporter loadReporter = new DefaultLoadReporter(base);
PatchReporter patchReporter = new DefaultPatchReporter(base);
PatchListener patchListener = new DefaultPatchListener(base);
public void install(Intent intentResult, Class extends AbstractResultService> serviceClass,
AbstractPatch upgradePatch) {
sInstalled = true;
//将UpgradePatch和DefaultTinkerResultService 组合进TinkerPatchService
chProcessor(upgradePatch, serviceClass);
TinkerLog.i(TAG, "try to install tinker, isEnable: %b, version: %s", isTinkerEnabled(), _VERSION);
if (!isTinkerEnabled()) {
TinkerLog.e(TAG, "tinker is disabled");
return;
}
if (intentResult == null) {
throw new TinkerRuntimeException("intentResult must not be null.");
}
tinkerLoadResult = new TinkerLoadResult();
TinkerLog.i(TAG, "parseTinkerResult loadCode:%d, process name:%s, main process:%b, systemOTA:%b, fingerPrint:%s, oatDir:%s, useInterpretMode:%b",
break;
// _DEX, false);
}
break;
case _LOAD_PATCH_VERSION_RESOURCE_MD5_MISMATCH:
if (resourceFile == null) {
TinkerLog.e(TAG, "resource file md5 mismatch, but patch resource file not found!");
throw new TinkerRuntimeException("resource file md5 mismatch, but patch resource file not found!");
}
I/LoadResult: parseTinkerResult loadCode:-3, process name:sdkdemo, main process:true, systemOTA:false, fingerPrint:Xiaomi/dipper/dipp
loadCode -3 :对应ERROR_LOAD_PATCH_INFO_NOT_EXIST
看看是什么原因set的


发布评论