Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tinker 接入 patch load成功,重启加载失败。patch包中的text.dex 的TinkerTestDexLoad isPatch值是true。但是重启加载检查checkDexInstall 中反射获取isPAatch一直是false。 #1727

Open
HeWenhui opened this issue Aug 18, 2023 · 2 comments

Comments

@HeWenhui
Copy link

Issue/提问须知

异常类型:app运行时异常

手机型号:如:红米 note4

手机系统版本:如:Android 6.0

tinker版本:1.9.14.25.2

gradle版本:6.7.1

是否使用热更新SDK: TinkerPatch SDK

堆栈/日志:
加载插件:
2023-08-18 17:14:20.381 26294-26294/? V/Tinker.SamplePatchListener: receive a patch file: /data/user/0/com.example.msxftinker/cache/app-debug-patch_signed_7zip.apk, file size:20761
2023-08-18 17:14:20.387 26294-26294/? W/Tinker.PatchInfo: read property failed, e:java.io.FileNotFoundException: /data/user/0/com.example.msxftinker/tinker/patch.info: open failed: ENOENT (No such file or directory)
2023-08-18 17:14:20.387 26294-26294/? W/Tinker.PatchInfo: read property failed, e:java.io.FileNotFoundException: /data/user/0/com.example.msxftinker/tinker/patch.info: open failed: ENOENT (No such file or directory)
2023-08-18 17:14:20.388 26294-26294/? W/Tinker.UpgradePatchRetry: onPatchListenerCheck retry file is not exist, just return
2023-08-18 17:14:20.391 26294-26294/? V/Tinker.SamplePatchListener: get platform:all
2023-08-18 17:14:20.409 1257-11940/? I/ActivityManager: Start proc 26464:com.example.msxftinker:patch/u0a167 for service com.example.msxftinker/com.tencent.tinker.lib.service.TinkerPatchForeService
2023-08-18 17:14:20.409 26294-26294/? I/Tinker.TinkerPatchService: run patch service...
2023-08-18 17:14:20.489 26464-26464/? D/Tinker.TinkerLoader: tryLoad test test
2023-08-18 17:14:20.498 26464-26464/? W/Tinker.TinkerLoader: tryLoadPatchFiles: we don't load patch with :patch process itself, just return
2023-08-18 17:14:20.499 26464-26464/? D/Tinker.DefaultAppLike: onBaseContextAttached:
2023-08-18 17:14:20.504 26464-26464/? V/Tinker.SamplePatchListener: application maxMemory:256
2023-08-18 17:14:20.508 26464-26464/? W/Tinker.Tinker: tinker patch directory: /data/user/0/com.example.msxftinker/tinker
2023-08-18 17:14:20.509 26464-26464/? I/Tinker.Tinker: try to install tinker, isEnable: true, version: 1.9.14.25.2
2023-08-18 17:14:20.509 26464-26464/? I/Tinker.TinkerLoadResult: parseTinkerResult loadCode:-1, process name:com.example.msxftinker:patch, main process:false, systemOTA:false, fingerPrint:Xiaomi/nikel/nikel:6.0/MRA58K/V10.2.2.0.MBFCNXM:user/release-keys, oatDir:null, useInterpretMode:false
2023-08-18 17:14:20.510 26464-26464/? W/Tinker.TinkerLoadResult: tinker is disable, just return
2023-08-18 17:14:20.510 26464-26464/? I/Tinker.DefaultLoadReporter: patch loadReporter onLoadResult: patch load result, path:/data/user/0/com.example.msxftinker/tinker, code: -1, cost: 9ms
2023-08-18 17:14:20.511 26464-26464/? W/Tinker.Tinker: tinker load fail!
2023-08-18 17:14:20.518 26464-26464/? D/Tinker.DefaultAppLike: onCreate
2023-08-18 17:14:20.520 26464-26464/? D/ActivityThread: SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@2337ffa className=com.tencent.tinker.lib.service.TinkerPatchForeService packageName=com.example.msxftinker intent=null}
2023-08-18 17:14:20.520 26464-26464/? V/ActivityThread: handleBindService s=com.tencent.tinker.lib.service.TinkerPatchForeService@647d9ab rebind=false
2023-08-18 17:14:20.523 26464-26464/? D/ActivityThread: SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@62bf808 className=com.tencent.tinker.lib.service.TinkerPatchService packageName=com.example.msxftinker intent=null}
2023-08-18 17:14:20.525 26464-26464/? D/ActivityThread: SVC-Calling onStartCommand: com.tencent.tinker.lib.service.TinkerPatchService@47b3ba1, flags=0, startId=1
2023-08-18 17:14:20.525 26464-26480/? I/Tinker.TinkerPatchService: try to increase patch process priority
2023-08-18 17:14:20.526 26464-26464/? D/Tinker.TinkerLoader: [PendingLog @ 2023-08-18 17:14:20.489] tryLoad test test
2023-08-18 17:14:20.526 26464-26464/? W/Tinker.TinkerLoader: [PendingLog @ 2023-08-18 17:14:20.497] tryLoadPatchFiles: we don't load patch with :patch process itself, just return
2023-08-18 17:14:20.526 26464-26464/? D/Tinker.DefaultAppLike: [PendingLog @ 2023-08-18 17:14:20.499] onBaseContextAttached:
2023-08-18 17:14:20.526 26464-26464/? W/Tinker.UpgradePatchRetry: onPatchRetryLoad retry is not main process, just return
2023-08-18 17:14:20.527 1257-1276/? V/ActivityManager: Attempted to start a foreground service (ComponentInfo{com.example.msxftinker/com.tencent.tinker.lib.service.TinkerPatchService}) with a broken notification (no icon: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 vis=PRIVATE))
2023-08-18 17:14:20.534 26464-26464/? D/ActivityThread: SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@429a1c6 className=com.tencent.tinker.lib.service.TinkerPatchService$InnerService packageName=com.example.msxftinker intent=null}
2023-08-18 17:14:20.535 1257-1276/? V/ActivityManager: Attempted to start a foreground service (ComponentInfo{com.example.msxftinker/com.tencent.tinker.lib.service.TinkerPatchService$InnerService}) with a broken notification (no icon: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 vis=PRIVATE))
2023-08-18 17:14:20.535 26464-26480/? I/Tinker.DefaultPatchReporter: patchReporter onPatchServiceStart: patch service start
2023-08-18 17:14:20.536 26464-26464/? D/ActivityThread: SVC-Calling onStartCommand: com.tencent.tinker.lib.service.TinkerPatchService$InnerService@a286587, flags=0, startId=1
2023-08-18 17:14:20.536 26464-26464/? D/ActivityThread: SVC-Destroying service: com.tencent.tinker.lib.service.TinkerPatchService$InnerService@a286587
2023-08-18 17:14:20.540 26464-26480/? W/Tinker.UpgradePatchRetry: try copy file: /data/user/0/com.example.msxftinker/cache/app-debug-patch_signed_7zip.apk to /data/user/0/com.example.msxftinker/tinker_temp/temp.apk
2023-08-18 17:14:20.554 26464-26480/? I/Tinker.UpgradePatch: UpgradePatch tryPatch:patchMd5:d534f65a770993721fd0d783f5e403f1
2023-08-18 17:14:20.555 26464-26480/? W/Tinker.PatchInfo: read property failed, e:java.io.FileNotFoundException: /data/user/0/com.example.msxftinker/tinker/patch.info: open failed: ENOENT (No such file or directory)
2023-08-18 17:14:20.555 26464-26480/? W/Tinker.PatchInfo: read property failed, e:java.io.FileNotFoundException: /data/user/0/com.example.msxftinker/tinker/patch.info: open failed: ENOENT (No such file or directory)
2023-08-18 17:14:20.555 26464-26480/? I/Tinker.UpgradePatch: UpgradePatch tryPatch:patchVersionDirectory:/data/user/0/com.example.msxftinker/tinker/patch-d534f65a
2023-08-18 17:14:20.557 26464-26480/? W/Tinker.UpgradePatch: UpgradePatch copy patch file, src file: /data/user/0/com.example.msxftinker/cache/app-debug-patch_signed_7zip.apk size: 20761, dest file: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/patch-d534f65a.apk size:20761
2023-08-18 17:14:20.858 26464-26480/? W/Tinker.DexDiffPatchInternal: success recover dex file: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/classes.dex.jar, size: 161798, use time: 296
2023-08-18 17:14:22.447 26464-26480/? W/Tinker.DexDiffPatchInternal: success recover dex file: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/classes2.dex.jar, size: 916992, use time: 1588
2023-08-18 17:14:22.447 26464-26480/? I/Tinker.DexDiffPatchInternal: try Extracting /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/test.dex.jar
2023-08-18 17:14:22.448 26464-26480/? I/Tinker.DexDiffPatchInternal: isExtractionSuccessful: true
2023-08-18 17:14:22.523 26464-26480/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/test.dex.jar
2023-08-18 17:14:22.523 26464-26480/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/classes2.dex.jar
2023-08-18 17:14:22.524 26464-26480/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/classes.dex.jar
2023-08-18 17:14:22.525 26464-26480/? I/Tinker.DexDiffPatchInternal: merge classN dex file /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk, result: true, size: 2589283, use: 76ms
2023-08-18 17:14:22.525 26464-26480/? I/Tinker.DexDiffPatchInternal: legal files to do dexopt: [/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk]
2023-08-18 17:14:22.527 26464-26480/? I/Tinker.DexDiffPatchInternal: patch recover, try to optimize dex file count:1, optimizeDexDirectory:/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/odex/
2023-08-18 17:14:22.529 26464-26480/? D/Tinker.TinkerInternals: getCurrentInstructionSet:arm64
2023-08-18 17:14:22.529 26464-26480/? I/Tinker.DexDiffPatchInternal: start to parallel optimize dex /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk, size: 2589283
2023-08-18 17:14:22.530 26464-26480/? I/Tinker.TinkerInternals: class not found exception
2023-08-18 17:14:23.439 26482-26491/? W/dex2oat: Compilation of boolean com.tencent.tinker.lib.tinker.TinkerLoadResult.parseTinkerResult(android.content.Context, android.content.Intent) took 115.720ms
2023-08-18 17:14:24.666 26464-26480/? I/Tinker.DexDiffPatchInternal: success to parallel optimize dex /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk, opt file:/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/odex/tinker_classN.dex, opt file size: 7078568, use time 2137
2023-08-18 17:14:24.667 26464-26480/? I/Tinker.DexDiffPatchInternal: recover dex result:true, cost:4109
2023-08-18 17:14:24.668 26464-26480/? W/Tinker.BsDiffPatchInternal: patch recover, library is not contained
2023-08-18 17:14:24.668 26464-26480/? W/Tinker.ResDiffPatchInternal: patch recover, resource is not contained
2023-08-18 17:14:24.668 26464-26480/? I/Tinker.DexDiffPatchInternal: raw dex count: 3, dex opt dex count: 1, final wait times: 90
2023-08-18 17:14:24.677 26464-26480/? I/Tinker.DexDiffPatchInternal: check dex optimizer file exist: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/odex/tinker_classN.dex, size 7078568
2023-08-18 17:14:24.677 26464-26480/? I/Tinker.DexDiffPatchInternal: check dex optimizer file format: tinker_classN.dex, size 7078568
2023-08-18 17:14:24.681 26464-26480/? I/Tinker.PatchInfo: rewritePatchInfoFile file path:/data/user/0/com.example.msxftinker/tinker/patch.info , oldVer:, newVer:d534f65a770993721fd0d783f5e403f1, isProtectedApp:0, versionToRemove:, fingerprint:Xiaomi/nikel/nikel:6.0/MRA58K/V10.2.2.0.MBFCNXM:user/release-keys, oatDir:odex, isRemoveInterpretOATDir:0, stack: java.lang.Throwable
at com.tencent.tinker.loader.shareutil.SharePatchInfo.rewritePatchInfoFile(SharePatchInfo.java:189)
at com.tencent.tinker.loader.shareutil.SharePatchInfo.rewritePatchInfoFileWithLock(SharePatchInfo.java:106)
at com.tencent.tinker.lib.patch.UpgradePatch.tryPatch(UpgradePatch.java:200)
at com.tencent.tinker.lib.service.TinkerPatchService.doApplyPatch(TinkerPatchService.java:238)
at com.tencent.tinker.lib.service.TinkerPatchService.onHandleIntent(TinkerPatchService.java:114)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.os.HandlerThread.run(HandlerThread.java:61)
2023-08-18 17:14:24.692 26464-26480/? I/Tinker.UpgradePatchRetry: onPatchResetMaxCheck, reset max check to 1
2023-08-18 17:14:24.693 26464-26480/? W/Tinker.UpgradePatch: UpgradePatch tryPatch: done, it is ok
2023-08-18 17:14:24.693 26464-26480/? I/Tinker.DefaultPatchReporter: patchReporter onPatchResult: patch all result path: /data/user/0/com.example.msxftinker/cache/app-debug-patch_signed_7zip.apk, success: true, cost: 4150
2023-08-18 17:14:24.693 26464-26480/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker_temp/temp.apk
2023-08-18 17:14:24.706 26464-26464/? D/ActivityThread: SVC-Destroying service: com.tencent.tinker.lib.service.TinkerPatchService@47b3ba1
2023-08-18 17:14:24.717 26294-26495/? V/Tinker.SampleResultService: SampleResultService receive result:
PatchResult:
isSuccess:true
rawPatchFilePath:/data/user/0/com.example.msxftinker/cache/app-debug-patch_signed_7zip.apk
useEmergencyMode:false
costTime:4150
dexoptTriggerTime:1692350062527
isOatGenerated:true
patchVersion:d534f65a770993721fd0d783f5e403f1
2023-08-18 17:14:24.722 26294-26495/? W/Tinker.DefaultTinkerResultService: deleteRawPatchFile rawFile path: /data/user/0/com.example.msxftinker/cache/app-debug-patch_signed_7zip.apk
2023-08-18 17:14:24.723 26294-26495/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/cache/app-debug-patch_signed_7zip.apk
2023-08-18 17:14:24.723 26294-26495/? V/Tinker.SampleResultService: tinker wait screen to restart process

重启加载:

2023-08-18 17:15:33.036 26552-26552/? D/Tinker.TinkerLoader: tryLoad test test
2023-08-18 17:15:33.058 26552-26552/? I/Tinker.TinkerInternals: class not found exception
2023-08-18 17:15:33.060 26552-26552/? W/Tinker.TinkerLoader: tryLoadPatchFiles:isEnabledForResource:true
2023-08-18 17:15:33.060 26552-26552/? D/Tinker.TinkerInternals: same fingerprint:Xiaomi/nikel/nikel:6.0/MRA58K/V10.2.2.0.MBFCNXM:user/release-keys
2023-08-18 17:15:33.060 26552-26552/? W/Tinker.TinkerInternals: getSafeModeCount: recFileName:safemode_count_rec_com.example.msxftinker failed, return 0 instead.
2023-08-18 17:15:33.061 26552-26552/? I/Tinker.TinkerInternals: setSafeModeCount: count: 1
2023-08-18 17:15:33.061 26552-26552/? I/Tinker.TinkerDexLoader: classloader: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.msxftinker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.msxftinker-1/lib/arm64, /vendor/lib64, /system/lib64]]]
2023-08-18 17:15:33.061 26552-26552/? I/Tinker.TinkerDexLoader: verify dex file:/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk md5, use time: 0
2023-08-18 17:15:33.062 26552-26552/? I/Tinker.ClassLoaderAdder: installDexes dexOptDir: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/odex, dex size:1
2023-08-18 17:15:33.073 26552-26552/? I/Tinker.ClassLoaderAdder: after loaded classloader: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk", zip file "/data/app/com.example.msxftinker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.msxftinker-1/lib/arm64, /vendor/lib64, /system/lib64]]], dex size:1
2023-08-18 17:15:33.074 26552-26552/? I/Tinker.ClassLoaderAdder: checkDexInstall result: false, checker_classloader: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk", zip file "/data/app/com.example.msxftinker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.msxftinker-1/lib/arm64, /vendor/lib64, /system/lib64]]]
2023-08-18 17:15:33.074 26552-26552/? E/Tinker.TinkerDexLoader: install dexes failed
2023-08-18 17:15:33.074 26552-26552/? W/Tinker.TinkerLoader: tryLoadPatchFiles:onPatchLoadDexesFail
2023-08-18 17:15:33.075 26552-26552/? D/Tinker.DefaultAppLike: onBaseContextAttached:
2023-08-18 17:15:33.076 26552-26552/? V/Tinker.SamplePatchListener: application maxMemory:256
2023-08-18 17:15:33.079 26552-26552/? W/Tinker.Tinker: tinker patch directory: /data/user/0/com.example.msxftinker/tinker
2023-08-18 17:15:33.080 26552-26552/? I/Tinker.Tinker: try to install tinker, isEnable: true, version: 1.9.14.25.2
2023-08-18 17:15:33.080 26552-26552/? I/Tinker.TinkerLoadResult: parseTinkerResult loadCode:-14, process name:com.example.msxftinker, main process:true, systemOTA:false, fingerPrint:Xiaomi/nikel/nikel:6.0/MRA58K/V10.2.2.0.MBFCNXM:user/release-keys, oatDir:odex, useInterpretMode:false
2023-08-18 17:15:33.081 26552-26552/? I/Tinker.TinkerLoadResult: parseTinkerResult oldVersion:, newVersion:d534f65a770993721fd0d783f5e403f1, current:d534f65a770993721fd0d783f5e403f1
2023-08-18 17:15:33.081 26552-26552/? I/Tinker.TinkerLoadResult: Tinker load have exception loadCode:-14
2023-08-18 17:15:33.081 26552-26552/? E/Tinker.DefaultLoadReporter: patch loadReporter onLoadException: tinker dex check fail:Tinker Exception:checkDexInstall failed
2023-08-18 17:15:33.087 26552-26552/? I/Tinker.DefaultLoadReporter: dex exception disable tinker forever with sp
2023-08-18 17:15:33.087 26552-26552/? E/Tinker.DefaultLoadReporter: tinker load exception, welcome to submit issue to us: https://github.com/Tencent/tinker/issues
2023-08-18 17:15:33.087 26552-26552/? E/Tinker.DefaultLoadReporter: tinker load exception com.tencent.tinker.loader.TinkerRuntimeException: Tinker Exception:checkDexInstall failed
at com.tencent.tinker.loader.SystemClassLoaderAdder.installDexes(SystemClassLoaderAdder.java:73)
at com.tencent.tinker.loader.TinkerDexLoader.loadTinkerJars(TinkerDexLoader.java:191)
at com.tencent.tinker.loader.TinkerLoader.tryLoadPatchFilesInternal(TinkerLoader.java:346)
at com.tencent.tinker.loader.TinkerLoader.tryLoad(TinkerLoader.java:57)
at java.lang.reflect.Method.invoke(Native Method)
at com.tencent.tinker.loader.app.TinkerApplication.loadTinker(TinkerApplication.java:125)
at com.tencent.tinker.loader.app.TinkerApplication.onBaseContextAttached(TinkerApplication.java:163)
at com.tencent.tinker.loader.app.TinkerApplication.attachBaseContext(TinkerApplication.java:186)
at android.app.Application.attach(Application.java:189)
at android.app.Instrumentation.newApplication(Instrumentation.java:1002)
at android.app.Instrumentation.newApplication(Instrumentation.java:986)
at android.app.LoadedApk.makeApplication(LoadedApk.java:588)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4992)
at android.app.ActivityThread.access$1800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1578)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)
2023-08-18 17:15:33.088 26552-26552/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/patch-d534f65a.apk
2023-08-18 17:15:33.089 26552-26552/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk
2023-08-18 17:15:33.090 26552-26552/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex
2023-08-18 17:15:33.090 26552-26552/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/odex/tinker_classN.dex
2023-08-18 17:15:33.091 26552-26552/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/odex
2023-08-18 17:15:33.091 26552-26552/? I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a
2023-08-18 17:15:33.092 26552-26552/? I/Tinker.PatchInfo: rewritePatchInfoFile file path:/data/user/0/com.example.msxftinker/tinker/patch.info , oldVer:, newVer:, isProtectedApp:0, versionToRemove:, fingerprint:Xiaomi/nikel/nikel:6.0/MRA58K/V10.2.2.0.MBFCNXM:user/release-keys, oatDir:odex, isRemoveInterpretOATDir:0, stack: java.lang.Throwable
at com.tencent.tinker.loader.shareutil.SharePatchInfo.rewritePatchInfoFile(SharePatchInfo.java:189)
at com.tencent.tinker.loader.shareutil.SharePatchInfo.rewritePatchInfoFileWithLock(SharePatchInfo.java:106)
at com.tencent.tinker.loader.shareutil.ShareTinkerInternals.cleanPatch(ShareTinkerInternals.java:764)
at com.tencent.tinker.lib.tinker.Tinker.cleanPatch(Tinker.java:266)
at com.tencent.tinker.lib.reporter.DefaultLoadReporter.checkAndCleanPatch(DefaultLoadReporter.java:307)
at com.tencent.tinker.lib.reporter.DefaultLoadReporter.onLoadException(DefaultLoadReporter.java:280)
at com.example.msxftinker.reporter.SampleLoadReporter.onLoadException(SampleLoadReporter.java:68)
at com.tencent.tinker.lib.tinker.TinkerLoadResult.parseTinkerResult(TinkerLoadResult.java:143)
at com.tencent.tinker.lib.tinker.Tinker.install(Tinker.java:156)
at com.tencent.tinker.lib.tinker.TinkerInstaller.install(TinkerInstaller.java:73)
at com.example.msxftinker.util.TinkerManager.installTinker(TinkerManager.java:98)
at com.example.msxftinker.app.SampleApplicationLike.onBaseContextAttached(SampleApplicationLike.java:97)
at com.tencent.tinker.entry.TinkerApplicationInlineFence.handleMessageImpl(TinkerApplicationInlineFence.java:72)
at com.tencent.tinker.entry.TinkerApplicationInlineFence.handleMessage_$noinline$(TinkerApplicationInlineFence.java:60)
at com.tencent.tinker.entry.TinkerApplicationInlineFence.handleMessage(TinkerApplicationInlineFence.java:53)
at com.tencent.tinker.loader.app.TinkerInlineFenceAction.callOnBaseContextAttached(TinkerInlineFenceAction.java:47)
at com.tencent.tinker.loader.app.TinkerApplication.onBaseContextAttached(TinkerApplication.java:168)
at com.tencent.tinker.loader.app.TinkerApplication.attachBaseContext(TinkerApplication.java:186)
at android.app.Application.attach(Application.java:189)
at android.app.Instrumentation.newApplication(Instrumentation.java:1002)
at android.app.Instrumentation.newApplication(Instrumentation.java:986)
at android.app.LoadedApk.makeApplication(LoadedApk.java:588)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4992)
at android.app.ActivityThread.access$1800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1578)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)
2023-08-18 17:15:33.093 26552-26552/? W/Tinker.PatchInfo: path info file corrupted:/data/user/0/com.example.msxftinker/tinker/patch.info
2023-08-18 17:15:33.093 26552-26552/? W/Tinker.PatchInfo: path info file corrupted:/data/user/0/com.example.msxftinker/tinker/patch.info
2023-08-18 17:15:33.095 26552-26552/? W/Tinker.PatchInfo: path info file corrupted:/data/user/0/com.example.msxftinker/tinker/patch.info
2023-08-18 17:15:33.095 26552-26552/? W/Tinker.PatchInfo: path info file corrupted:/data/user/0/com.example.msxftinker/tinker/patch.info
2023-08-18 17:15:33.096 26552-26552/? I/Tinker.DefaultLoadReporter: patch loadReporter onLoadResult: patch load result, path:/data/user/0/com.example.msxftinker/tinker, code: -14, cost: 38ms
2023-08-18 17:15:33.096 26552-26552/? W/Tinker.Tinker: tinker load fail!
2023-08-18 17:15:33.097 26552-26552/? I/Tinker.TinkerInternals: setSafeModeCount: count: 0
2023-08-18 17:15:33.100 26552-26552/? D/Tinker.DefaultAppLike: onCreate
2023-08-18 17:15:33.189 26552-26552/? E/Tinker.MainActivity: ARK HOT Running status = false
2023-08-18 17:15:33.189 26552-26552/? E/Tinker.MainActivity: i am on onCreate classloader:dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.msxftinker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.msxftinker-1/lib/arm64, /vendor/lib64, /system/lib64]]]
2023-08-18 17:15:33.189 26552-26552/? E/Tinker.MainActivity: i am on onCreate string:I am in the base apk
2023-08-18 17:15:33.191 26552-26552/? E/Tinker.MainActivity: i am on onResume
2023-08-18 17:15:33.214 26552-26552/? D/Tinker.TinkerLoader: [PendingLog @ 2023-08-18 17:15:33.036] tryLoad test test
2023-08-18 17:15:33.214 26552-26552/? I/Tinker.TinkerInternals: [PendingLog @ 2023-08-18 17:15:33.058] class not found exception
2023-08-18 17:15:33.214 26552-26552/? W/Tinker.TinkerLoader: [PendingLog @ 2023-08-18 17:15:33.060] tryLoadPatchFiles:isEnabledForResource:true
2023-08-18 17:15:33.214 26552-26552/? D/Tinker.TinkerInternals: [PendingLog @ 2023-08-18 17:15:33.060] same fingerprint:Xiaomi/nikel/nikel:6.0/MRA58K/V10.2.2.0.MBFCNXM:user/release-keys
2023-08-18 17:15:33.214 26552-26552/? W/Tinker.TinkerInternals: [PendingLog @ 2023-08-18 17:15:33.060] getSafeModeCount: recFileName:safemode_count_rec_com.example.msxftinker failed, return 0 instead.
2023-08-18 17:15:33.214 26552-26552/? I/Tinker.TinkerInternals: [PendingLog @ 2023-08-18 17:15:33.061] setSafeModeCount: count: 1
2023-08-18 17:15:33.215 26552-26552/? I/Tinker.TinkerDexLoader: [PendingLog @ 2023-08-18 17:15:33.061] classloader: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.msxftinker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.msxftinker-1/lib/arm64, /vendor/lib64, /system/lib64]]]
2023-08-18 17:15:33.215 26552-26552/? I/Tinker.TinkerDexLoader: [PendingLog @ 2023-08-18 17:15:33.061] verify dex file:/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk md5, use time: 0
2023-08-18 17:15:33.215 26552-26552/? I/Tinker.ClassLoaderAdder: [PendingLog @ 2023-08-18 17:15:33.062] installDexes dexOptDir: /data/user/0/com.example.msxftinker/tinker/patch-d534f65a/odex, dex size:1
2023-08-18 17:15:33.215 26552-26552/? I/Tinker.ClassLoaderAdder: [PendingLog @ 2023-08-18 17:15:33.073] after loaded classloader: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/user/0/com.example.msxftinker/tinker/patch-d534f65a/dex/tinker_classN.apk", zip file "/data/app/com.example.msxftinker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.msxftinker-1/lib/arm64, /vendor/lib64, /system/lib64]]], dex size:1
2023-08-18 17:15:33.215 26552-26552/? I/Tinker.ClassLoaderAdder: [PendingLog @ 2023-08-18 17:15:33.073] checkDexInstall result: false, checker_classloader: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.msxftinker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.msxftinker-1/lib/arm64, /vendor/lib64, /system/lib64]]]
2023-08-18 17:15:33.215 26552-26552/? E/Tinker.TinkerDexLoader: [PendingLog @ 2023-08-18 17:15:33.074] install dexes failed
2023-08-18 17:15:33.216 26552-26552/? W/Tinker.TinkerLoader: [PendingLog @ 2023-08-18 17:15:33.074] tryLoadPatchFiles:onPatchLoadDexesFail
2023-08-18 17:15:33.216 26552-26552/? D/Tinker.DefaultAppLike: [PendingLog @ 2023-08-18 17:15:33.075] onBaseContextAttached:
2023-08-18 17:15:33.292 26552-26552/? W/Tinker.UpgradePatchRetry: onPatchRetryLoad patch file: /data/user/0/com.example.msxftinker/tinker_temp/temp.apk is not exist, just return

@woshishuxiong
Copy link

之前遇到过类似的问题,是因为检查的时候拿到的是apk内自带的TinkerTestDexLoad,不是补丁包内的。临时解决方法是打包的时候把TinkerTestDexLoad去掉。

@draty01
Copy link

draty01 commented Dec 4, 2023

问题原因是,合成的tinker_classN.apk中,用来检测patch 的 test.dex 放在最后,class load 的时候,就被前面的抢先了。
不知道为啥他们这么设计

我自己简单改了下。


---
Index: tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerDexLoader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerDexLoader.java b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerDexLoader.java
--- a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerDexLoader.java	(revision a9c4b7aee1319bf4f4b524e2fe7d700ce1404382)
+++ b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerDexLoader.java	(date 1701688205021)
@@ -224,7 +224,7 @@
         HashMap<String, String> dexes = new HashMap<>();
 
         ShareDexDiffPatchInfo testInfo = null;
-
+        HashSet<ShareDexDiffPatchInfo> myClassNDexInfo = new HashSet<>();
         for (ShareDexDiffPatchInfo info : allDexInfo) {
             //for dalvik, ignore art support dex
             if (isJustArtSupportDex(info)) {
@@ -238,7 +238,7 @@
             if (isVmArt && info.rawName.startsWith(ShareConstants.TEST_DEX_NAME)) {
                 testInfo = info;
             } else if (isVmArt && ShareConstants.CLASS_N_PATTERN.matcher(info.realName).matches()) {
-                classNDexInfo.add(info);
+                myClassNDexInfo.add(info);
             } else {
                 dexes.put(info.realName, getInfoMd5(info));
                 LOAD_DEX_LIST.add(info);
@@ -246,12 +246,15 @@
         }
 
         if (isVmArt
-            && (testInfo != null || !classNDexInfo.isEmpty())) {
+            && (testInfo != null || !myClassNDexInfo.isEmpty())) {
             if (testInfo != null) {
                 classNDexInfo.add(ShareTinkerInternals.changeTestDexToClassN(testInfo, classNDexInfo.size() + 1));
             }
             dexes.put(ShareConstants.CLASS_N_APK_NAME, "");
         }
+        for (ShareDexDiffPatchInfo info : myClassNDexInfo) {
+            classNDexInfo.add(ShareTinkerInternals.changeDexToClassN(info, classNDexInfo.size() + 1));
+        }
         //tinker/patch.info/patch-641e634c/dex
         String dexDirectory = directory + "/" + DEX_PATH + "/";
 
Index: tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java
--- a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java	(revision a9c4b7aee1319bf4f4b524e2fe7d700ce1404382)
+++ b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java	(date 1701688205037)
@@ -190,6 +190,17 @@
         return null;
     }
 
+    public static ShareDexDiffPatchInfo changeDexToClassN(ShareDexDiffPatchInfo rawDexInfo, int index){
+        String newName;
+        if (index != 1) {
+            newName = "classes" + index + ".dex";
+        } else {
+            newName = "classes.dex";
+        }
+        return new ShareDexDiffPatchInfo(newName, rawDexInfo.path, rawDexInfo.destMd5InDvm, rawDexInfo.destMd5InArt,
+                rawDexInfo.dexDiffMd5, rawDexInfo.oldDexCrC, rawDexInfo.newOrPatchedDexCrC, rawDexInfo.dexMode);
+    }
+
     public static boolean isNullOrNil(final String object) {
         if ((object == null) || (object.length() <= 0)) {
             return true;


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants