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

加载第二次补丁err code:-6 #1093

Open
ContainsK opened this issue May 10, 2019 · 10 comments

Comments

@ContainsK
Copy link

commented May 10, 2019

异常类型:app运行时异常/编译异常

手机型号:Google模拟器 Nexus5

手机系统版本:Android 8.0

tinker版本:1.9.13

gradle版本:3.2.1

是否使用热更新SDK: 用的官方demo

系统:win10/win7

堆栈/日志:
Tinker.DefaultLoadReporter: patch loadReporter onLoadPatchListenerReceiveFail: patch receive fail: /storage/emulated/0/patch_signed_7zip.apk, code: -6

我需要在同一个base APK 中 加载两次 Patch
使用官方Demo 加载第一次Patch 成功,第二次 提示code -6
修改了patchVersion / TINKER_ID 也没用
是需要clear patch 后才能加载吗? 还是我的使用方式不对?

@tomystang

This comment has been minimized.

Copy link
Collaborator

commented May 13, 2019

-6表示当前这个patch已经被加载了。不要修改TinkerID,在产生第二个patch之前相对于第一个patch的变更再多加一些变更,然后再试试看?

@staticzh

This comment has been minimized.

Copy link

commented May 15, 2019

@ContainsK 我也遇到了这个问题,请问解决了吗

@staticzh

This comment has been minimized.

Copy link

commented May 15, 2019

解决了,是版本的问题,1.9.1版本没问题,1.9.13版本会出现这个问题

@ContainsK

This comment has been minimized.

Copy link
Author

commented May 27, 2019

-6表示当前这个patch已经被加载了。不要修改TinkerID,在产生第二个patch之前相对于第一个patch的变更再多加一些变更,然后再试试看?

BaseApk version:1.0
BaseApk-Patch-01: patchVersion 1.0.0.1 ,tinkerId 1.0 // result = OK
BaseApk-Patch-01: patchVersion 1.0.0.1 ,tinkerId 1.0 // result = code -6
BaseApk-Patch-01: patchVersion 1.0.0.2 ,tinkerId 1.0 // result = code -6
BaseApk-Patch-01: patchVersion 1.0.0.1 ,tinkerId 1.1 // result = code -6

经过几次测试只有第一次 patch 生效,后面几次都是 code -6 。并且相对于上一个Patch有增加多次变更,清除Patch后可以成功。

以下是在build patch的时候 打印的 md5
第一次
Analyze old and new apk files:
old apk: app-release.apk, size=2287872, md5=f63c3bc0b93e670e27480a96b26f7aef
new apk: app-release.apk, size=2287820, md5=b90cdc4eb94649059a2567f2afdf5c8d
第二次
Analyze old and new apk files:
old apk: app-release.apk, size=2287872, md5=f63c3bc0b93e670e27480a96b26f7aef
new apk: app-release.apk, size=2287712, md5=89091e84aa2d6dd7a1d62bd0928c5105
第三次
Analyze old and new apk files:
old apk: app-release.apk, size=2287872, md5=f63c3bc0b93e670e27480a96b26f7aef
new apk: app-release.apk, size=2287912, md5=de0e01e2e5b112ef0d72bb4fc73aee9d

唯一相同的是 :
Add test install result dex: D:*\app\build\outputs\apk\tinkerPatch\release\tinker_result\test.dex, size:584
DexDecoder:write test dex meta file data: test.dex,,56900442eb5b7e1de45449d0685e6e00,56900442eb5b7e1de45449d0685e6e00,0,0,0,jar

#1093 (comment)
也遇到相同问题,他修改版本号后解决了。

@tomystang

This comment has been minimized.

Copy link
Collaborator

commented May 27, 2019

@ContainsK
诡异了,我用demo按同样的步骤就复现不出来,而且检查patch是否加载过的代码确实只看patch的md5,按道理来说应该不会被判成已经加载过的。

有空的话能试试看用repo里的demo能复现吗?能复现的话发下操作步骤吧。

@ContainsK

This comment has been minimized.

Copy link
Author

commented May 27, 2019

@ContainsK
诡异了,我用demo按同样的步骤就复现不出来,而且检查patch是否加载过的代码确实只看patch的md5,按道理来说应该不会被判成已经加载过的。

有空的话能试试看用repo里的demo能复现吗?能复现的话发下操作步骤吧。

我通过源码跟踪到 下面代码,并且打印出 currInfo.newVersion 的值,发现它的值是 上一个补丁的 md5值,并不是最新的 md5 值

System.out: ce89feabd664de039424984d47a5d415 - false request ERROR_PATCH_ALREADY_APPLY

System.err: file /storage/emulated/0/patch_signed_7zip.apk md5 ea0e1ae57fa5aaf84d266fd1e2345a71

tinker-android-lib
com.tencent.tinker.lib.listener.DefaultPatchListener :106 行

我将该处逻辑 修改后 可以解决 code -6 问题,但是不知道这样会不会有副作用,大佬可以看看此处是不是有问题。

这是我修改后的代码:

image

@TracyZhangLei

This comment has been minimized.

Copy link

commented May 29, 2019

@nevermere

This comment has been minimized.

Copy link

commented May 29, 2019

更新补丁之前,清理已加载的补丁包,再进行加载,亲测可以。
Utils.setBackground(true);
TinkerInstaller.cleanPatch(this);
TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), filePath);

@ContainsK

This comment has been minimized.

Copy link
Author

commented May 31, 2019

更新补丁之前,清理已加载的补丁包,再进行加载,亲测可以。
Utils.setBackground(true);
TinkerInstaller.cleanPatch(this);
TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), filePath);

你这方式 治标不治本,没考虑到清理已加载的补丁包后加载失败怎么办?
目前只能重写 DefaultPatchListener 类去解决

tomystang added a commit that referenced this issue Jun 4, 2019
@tomystang tomystang added bug and removed question undetermined labels Jun 4, 2019
@DragonZJH

This comment has been minimized.

Copy link

commented Sep 13, 2019

09-13 17:56:04.972 4854-4854 W/Tinker.ClientImpl: [retryAllReportFails], there is no fail report, just return
09-13 17:56:04.984 4854-4854 I/Tinker.UrlConnectionFetcher: loadData from url: http://q.tinkerpatch.com/f6a3113e10555eae/19.9.11.03?d=1bd7b52b-7af5-41c9-bede-4f159122c85c&v=1568368564984, method:GET, body:null
09-13 17:56:05.069 4854-4922 I/Tinker.UrlConnectionFetcher: response code 200 msg: OK
09-13 17:56:05.069 4854-4922 I/Tinker.ClientImpl: tinker server sync respond:{"v":2}
09-13 17:56:05.070 4854-4922 I/Tinker.VersionInfo: VersionCheck: target version 2 is not latest. current version is 2
09-13 17:56:05.073 4854-4922 I/Tinker.VersionInfo: updateVersionInfo file path:/data/user/0/com.example.administrator.myapplication_tcp/tinker_server/f6a3113e10555eae_version.info, appVersion: 19.9.11.03, uuid:1bd7b52b-7af5-41c9-bede-4f159122c85c, abi:arm64-v8a, patchVersion:2, patchMd5:740015bff02d1be09830b48c2b057831, grayValue:5, crashTimes:0, retryTimes:1, applySuccess:0, patchSuccess:0
09-13 17:56:05.077 4854-4922 I/Tinker.TinkerServerPatchListener: receive a patch file: /data/user/0/com.example.administrator.myapplication_tcp/tinker_server/19.9.11.03_2.apk, file size:4017
09-13 17:56:05.083 4854-4922 I/Tinker.DefaultLoadReporter: patch loadReporter onLoadPatchListenerReceiveFail: patch receive fail: /data/user/0/com.example.administrator.myapplication_tcp/tinker_server/19.9.11.03_2.apk, code: -6
09-13 17:56:05.083 4854-4922 I/Tinker.ClientImpl: Fetch result: needn't update, gray: 5

你们说的-6是不是这个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.