Bugly热更新修复失败的一种解决方法(Tinker Exception:can't recognize dex mode:)

最近在项目中接入bugly的热修复功能,按照文档来做:https://bugly.qq.com/docs/user-guide/instruction-manual-android-hotfix-demo/ 。但是我发现了一个问题,就是在后台总是显示如下图这样的问题:
这里写图片描述

就是补丁显示已下发,但是激活总是0,也就是可能是下载补丁成功了,但是却没有安装成功。

通过打开log查看原因,打开方式如下图:
这里写图片描述
结果发现,当补丁下载成功后,我的后续操作就报错了,主要是下面一句:

Throwable:Tinker Exception:can't recognize dex mode:XXXX.jar

解决方案:
在我的项目的build.gradle中配置如下:

classpath "com.tencent.bugly:tinker-support:latest.release"

在我的app模块的build.gradle中配置如下:

compile 'com.tencent.bugly:crashreport_upgrade:1.3.4'
//compile 'com.tencent.bugly:crashreport_upgrade:1.3.1'
//1.3.1是我出问题的版本

这样再次重新走热更新的测试流程:
如下:

01-03 22:37:37.574 28526-28696/? I/Tinker.TinkerResultService: TinkerResultService receive result: 
                                                               PatchResult: 
                                                               isSuccess:true
                                                               rawPatchFilePath:/data/user/0/我的包名/app_tmpPatch/tmpPatch.apk
                                                               costTime:5961
                                                               patchVersion:495495fb58416dd186c6b439345c0124
01-03 22:37:37.576 28526-28526/? I/CrashReport: Tinker patch success, result: 
                                                PatchResult: 
                                                isSuccess:true
                                                rawPatchFilePath:/data/user/0/我的包名/app_tmpPatch/tmpPatch.apk
                                                costTime:5961
                                                patchVersion:495495fb58416dd186c6b439345c0124

这次就可以了,原因应该是导入的库版本不一致导致的。文档中是:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        // tinkersupport插件, 其中lastest.release指拉取最新版本,也可以指定明确版本号,例如1.0.4
        classpath "com.tencent.bugly:tinker-support:1.0.8"
    }
}

而我在配置时改成了:

classpath "com.tencent.bugly:tinker-support:latest.release"

所以发生了错误,只要保证app模块的crashreport_upgrade库版本相应提升即可。

猜你喜欢

转载自blog.csdn.net/y505772146/article/details/78966676