Tencent / tinker

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
Other
17.17k stars 3.34k forks source link

类文件修改后的补丁不生效 #1060

Closed whytot closed 5 years ago

whytot commented 5 years ago

异常类型:app运行时异常

手机型号:荣耀9 lite

手机系统版本:8.0

tinker版本:如:1.9.11

gradle版本:如:3.3.2

是否使用热更新SDK: false

系统:如:Windows 10

问题描述:

  1. 自己写的demo,未使用官方demo

  2. 单独修改res资源文件可以生效;如果修改类文件那么就不会生效生效

  3. crash日志 3.1 安装补丁

_2019-04-03 18:20:39.483 31186-31186/com.example.hotfixtest I/Tinker.TinkerPatchService: run patch service... 2019-04-03 18:20:43.231 31186-31456/com.example.hotfixtest I/Tinker.DefaultTinkerResultService: DefaultTinkerResultService received a result: PatchResult: isSuccess:true rawPatchFilePath:/storage/emulated/0/1/patch_signed.apk costTime:3390 patchVersion:bcd8d4948635fc22051f5aa10fd8f7d7

2019-04-03 18:20:43.234 31186-31456/com.example.hotfixtest W/Tinker.DefaultTinkerResultService: deleteRawPatchFile rawFile path: /storage/emulated/0/1/patch_signed.apk 2019-04-03 18:20:43.234 31186-31456/com.example.hotfixtest I/Tinker.PatchFileUtil: safeDeleteFile, try to delete path: /storage/emulated/0/1/patchsigned.apk

3.2 安装后重启 _2019-04-03 18:22:30.659 31512-31512/com.example.hotfixtest D/Tinker.TinkerInternals: getCurrentInstructionSet:arm64 2019-04-03 18:22:30.660 31512-31512/com.example.hotfixtest W/Tinker.TinkerLoader: tryLoadPatchFiles:isEnabledForResource:true 2019-04-03 18:22:30.660 31512-31512/com.example.hotfixtest D/Tinker.TinkerInternals: same fingerprint:HONOR/LLD-AL10/HWLLD-H:8.0.0/HONORLLD-AL10/186(C00):user/release-keys 2019-04-03 18:22:30.660 31512-31512/com.example.hotfixtest I/Tinker.PatchInfo: rewritePatchInfoFile file path:/data/user/0/com.example.hotfixtest/tinker/patch.info , oldVer:bcd8d4948635fc22051f5aa10fd8f7d7, newVer:bcd8d4948635fc22051f5aa10fd8f7d7, isRemoveNewVersion:0, fingerprint:HONOR/LLD-AL10/HWLLD-H:8.0.0/HONORLLD-AL10/186(C00):user/release-keys, oatDir:odex 2019-04-03 18:22:30.665 31512-31512/com.example.hotfixtest I/Tinker.TinkerLoader: tryLoadPatchFiles:success to rewrite patch info, kill other process. 2019-04-03 18:22:30.669 31512-31512/com.example.hotfixtest W/Tinker.TinkerInternals: getSafeModeCount: preferName:tinker_own_config_com.example.hotfixtest count:0 2019-04-03 18:22:30.738 31512-31512/com.example.hotfixtest W/Tinker.TinkerInternals: setSafeModeCount: preferName:tinker_own_config_com.example.hotfixtest count:1 2019-04-03 18:22:30.738 31512-31512/com.example.hotfixtest I/Tinker.TinkerDexLoader: classloader: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.hotfixtest-YuGV7f6WzIAqiXM7iYVGwQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.hotfixtest-YuGV7f6WzIAqiXM7iYVGwQ==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]] 2019-04-03 18:22:30.738 31512-31512/com.example.hotfixtest I/Tinker.TinkerDexLoader: verify dex file:/data/user/0/com.example.hotfixtest/tinker/patch-bcd8d494/dex/tinker_classN.apk md5, use time: 0 2019-04-03 18:22:30.739 31512-31512/com.example.hotfixtest I/Tinker.ClassLoaderAdder: installDexes dexOptDir: /data/user/0/com.example.hotfixtest/tinker/patch-bcd8d494/odex, dex size:1 2019-04-03 18:22:31.006 31512-31512/com.example.hotfixtest I/Tinker.ClassLoaderAdder: after loaded classloader: com.tencent.tinker.loader.AndroidNClassLoader[DexPathList[[zip file "/data/user/0/com.example.hotfixtest/tinker/patch-bcd8d494/dex/tinker_classN.apk", zip file "/data/app/com.example.hotfixtest-YuGV7f6WzIAqiXM7iYVGwQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.hotfixtest-YuGV7f6WzIAqiXM7iYVGwQ==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]], dex size:1 2019-04-03 18:22:31.007 31512-31512/com.example.hotfixtest W/Tinker.ClassLoaderAdder: checkDexInstall result:false 2019-04-03 18:22:31.007 31512-31512/com.example.hotfixtest E/Tinker.TinkerDexLoader: install dexes failed 2019-04-03 18:22:31.008 31512-31512/com.example.hotfixtest W/Tinker.TinkerLoader: tryLoadPatchFiles:onPatchLoadDexesFail 2019-04-03 18:22:31.009 31512-31512/com.example.hotfixtest D/Tinker.DefaultAppLike: onBaseContextAttached: 2019-04-03 18:22:31.016 31512-31512/com.example.hotfixtest W/Tinker.Tinker: tinker patch directory: /data/user/0/com.example.hotfixtest/tinker 2019-04-03 18:22:31.019 31512-31512/com.example.hotfixtest I/Tinker.Tinker: try to install tinker, isEnable: true, version: 1.9.11 2019-04-03 18:22:31.021 31512-31512/com.example.hotfixtest I/Tinker.TinkerLoadResult: parseTinkerResult loadCode:-14, process name:com.example.hotfixtest, main process:true, systemOTA:false, fingerPrint:HONOR/LLD-AL10/HWLLD-H:8.0.0/HONORLLD-AL10/186(C00):user/release-keys, oatDir:odex, useInterpretMode:false 2019-04-03 18:22:31.022 31512-31512/com.example.hotfixtest I/Tinker.TinkerLoadResult: parseTinkerResult oldVersion:, newVersion:bcd8d4948635fc22051f5aa10fd8f7d7, current:bcd8d4948635fc22051f5aa10fd8f7d7 2019-04-03 18:22:31.023 31512-31512/com.example.hotfixtest I/Tinker.TinkerLoadResult: Tinker load have exception loadCode:-14 2019-04-03 18:22:31.023 31512-31512/com.example.hotfixtest E/Tinker.DefaultLoadReporter: patch loadReporter onLoadException: tinker dex check fail:Tinker Exception:checkDexInstall failed 2019-04-03 18:22:31.028 31512-31512/com.example.hotfixtest I/Tinker.DefaultLoadReporter: dex exception disable tinker forever with sp 2019-04-03 18:22:31.028 31512-31512/com.example.hotfixtest E/Tinker.DefaultLoadReporter: tinker load exception, welcome to submit issue to us: https://github.com/Tencent/tinker/issues 2019-04-03 18:22:31.030 31512-31512/com.example.hotfixtest E/Tinker.DefaultLoadReporter: tinker load exception com.tencent.tinker.loader.TinkerRuntimeException: Tinker Exception:checkDexInstall failed at com.tencent.tinker.loader.SystemClassLoaderAdder.installDexes(SystemClassLoaderAdder.java:86) at com.tencent.tinker.loader.TinkerDexLoader.loadTinkerJars(TinkerDexLoader.java:194) at com.tencent.tinker.loader.TinkerLoader.tryLoadPatchFilesInternal(TinkerLoader.java:281) at com.tencent.tinker.loader.TinkerLoader.tryLoad(TinkerLoader.java:56) at java.lang.reflect.Method.invoke(Native Method) at com.tencent.tinker.loader.app.TinkerApplication.loadTinker(TinkerApplication.java:173) at com.tencent.tinker.loader.app.TinkerApplication.onBaseContextAttached(TinkerApplication.java:146) at com.tencent.tinker.loader.app.TinkerApplication.attachBaseContext(TinkerApplication.java:164) at android.app.Application.attach(Application.java:200) at android.app.Instrumentation.newApplication(Instrumentation.java:1105) at android.app.Instrumentation.newApplication(Instrumentation.java:1089) at android.app.LoadedApk.makeApplication(LoadedApk.java:1053) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6590) at android.app.ActivityThread.-wrap2(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7529) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 2019-04-03 18:22:31.033 31512-31512/com.example.hotfixtest I/Tinker.PatchInfo: rewritePatchInfoFile file path:/data/user/0/com.example.hotfixtest/tinker/patch.info , oldVer:bcd8d4948635fc22051f5aa10fd8f7d7, newVer:bcd8d4948635fc22051f5aa10fd8f7d7, isRemoveNewVersion:1, fingerprint:HONOR/LLD-AL10/HWLLD-H:8.0.0/HONORLLD-AL10/186(C00):user/release-keys, oatDir:odex 2019-04-03 18:22:31.038 31512-31512/com.example.hotfixtest I/Tinker.DefaultLoadReporter: patch loadReporter onLoadResult: patch load result, path:/data/user/0/com.example.hotfixtest/tinker, code: -14, cost: 436ms 2019-04-03 18:22:31.038 31512-31512/com.example.hotfixtest W/Tinker.Tinker: tinker load fail! 2019-04-03 18:22:31.042 31512-31512/com.example.hotfixtest W/Tinker.TinkerInternals: setSafeModeCount: preferName:tinker_own_configcom.example.hotfixtest count:0 2019-04-03 18:22:31.043 31512-31512/com.example.hotfixtest I/Tinker.ComponentHotplug: method install() is not invoked, ignore ensuring operations. 2019-04-03 18:22:31.043 31512-31512/com.example.hotfixtest D/Tinker.DefaultAppLike: onCreate

3.3 tinkerPatch.gradle配置

apply plugin: 'com.tencent.tinker.patch'
def bakPath = file("${buildDir}/bakApk/")
tinkerPatch {
    tinkerEnable = true
    oldApk "${bakPath}/oldApk.apk"
    newApk "${bakPath}/newApk.apk"
    ignoreWarning = true

    buildConfig {
        tinkerId "123"
        isProtectedApp false
        supportHotplugComponent false
    }
    dex {
        dexMode "jar"
        pattern = ["classes*.dex",
                   "assets/secondary-dex-?.jar"]
    }
    lib {
        pattern = ["lib/*/*.so"]
    }
    res { pattern = ["res/*", "assets/*", "resources.arsc", "AndroidManifest.xml"] }
    packageConfig {}
}
whytot commented 5 years ago

image

为什么会出现一个 test.dex ? 这里面有ThinkerTestDexLoad和Object两个类

classes.dex 无法在AS中预览

whytot commented 5 years ago

原来没有写7zip配置,一直使用patch_signed.apk作为patch 使用zipArtifact参数,改用patch_signed_7zip.apk作为patch

Licardo commented 5 years ago

你用patch_signed_7zip包,补丁可以生效了吗

whytot commented 5 years ago

你用patch_signed_7zip包,补丁可以生效了吗

可以