Tencent / tinker

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

TinkerPatchException:调用了没有加载的类XmlPullParser导致打补丁包失败 #1580

Closed xuetaotao closed 2 years ago

xuetaotao commented 3 years ago

Issue

执行buildTinkerPatchRelease打补丁异常,总是提示 tinker的 IncrementComponentManager$AttrTranslator类中调用了 XmlPullParser中的方法, 无法被loaded。请大佬们帮忙看看

异常类型:app编译异常:TinkerPatchException tinker版本:1.9.14.7 gradle版本:6.1.1 是否使用热更新SDK: TinkerPatch SDK 系统:Windows

堆栈/日志: `configuration: oldApk:C:\AndroidProgram\op-app-android\app\build\bakApk/app-0621-14-45-16/lishuaPro/app-lishua-pro-release.apk newApk:C:\AndroidProgram\op-app-android\app\build\outputs\apk\pro\release\��ˢ_3.2.6_326_unkown_release_lishua_pro.apk outputFolder:C:\AndroidProgram\op-app-android\app\build\outputs\apk\pro/tinkerPatch/lishuaPro/release isIgnoreWarning:false isAllowLoaderClassInAnyDex:false isRemoveLoaderForAllDex:false isProtectedApp:true 7-ZipPath:C:\Users\xuetaotao.gradle\caches\modules-2\files-2.1\com.tencent.mm\SevenZip\1.1.10\4786999cf29d8e3b0c39a80359b5127bda36132a\SevenZip-1.1.10-windows-x86_64.exe useSignAPk:true package meta fields: dex configs: dexMode: jar dexPattern:assets/secondary-dex-..jar dexPattern:classes..dex dex loader:com.shuabei.mpos.MyApplication dex loader:com.tencent.tinker.loader. lib configs: libPattern:lib/./..so resource configs: resPattern:r/. resPattern:resources.arsc resPattern:res/. resPattern:AndroidManifest.xml resPattern:assets/. resIgnore change:assets/._meta.txt largeModSize:100kb useApplyResource:false ArkHot: arkHot / patch.apk

config: arkHot patch.apkassets\arkHot_meta.txt Analyze old and new apk files1: old apk1131: app-lishua-pro-release.apk, size=61585801, md5=2c8be9eb8139112a779eb3723cff5b50 new apk: ��ˢ_3.2.6_326_unkown_release_lishua_pro.apk, size=61585801, md5=e2c303ad12e67cb3c35875a1974768f6

Manifest was changed, while there's no any new components added. Make sure if such changes were all you expected.

UnZipping apk to C:\AndroidProgram\op-app-android\app\build\outputs\apk\pro\tinkerPatch\lishuaPro\release\app-lishua-pro-release UnZipping apk to C:\AndroidProgram\op-app-android\app\build\outputs\apk\pro\tinkerPatch\lishuaPro\release\��ˢ_3.2.6_326_unkown_release_lishua_pro found modify resource: AndroidManifest.xml, but it is AndroidManifest.xml, just ignore! Check for loader classes in dex: classes.dex Collect class descriptors in classes.dex Check for loader classes in dex: classes2.dex Collect class descriptors in classes2.dex Check for loader classes in dex: classes3.dex Collect class descriptors in classes3.dex Check for loader classes in dex: classes4.dex Collect class descriptors in classes4.dex Found modify resource: res/layout/layout_login_with_pwd.xml Check if loader classes in classes.dex refer to any classes that is not in loader class patterns. Check if loader classes in classes2.dex refer to any classes that is not in loader class patterns. FATAL: method 'onInit:VLIL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$AttrTranslator;' refers to class 'Lorg/xmlpull/v1/XmlPullParser;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'translate:VLILL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$AttrTranslator;' refers to class 'Lorg/xmlpull/v1/XmlPullParser;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'translate:VLILL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$AttrTranslator;' refers to method 'getAttributeCount:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'translate:VLILL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$AttrTranslator;' refers to method 'getAttributePrefix:LI' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'translate:VLILL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$AttrTranslator;' refers to method 'getAttributeName:LI' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'translate:VLILL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$AttrTranslator;' refers to method 'getAttributeValue:LI' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'init:ZLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'setInput:VL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'init:ZLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getEventType:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'init:ZLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getName:L' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'init:ZLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'next:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'init:ZLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'setInput:VL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'init:ZLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'setInput:VL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseActivity:LLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to class 'Lorg/xmlpull/v1/XmlPullParser;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'parseActivity:LLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getDepth:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseActivity:LLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'next:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseActivity:LLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getDepth:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseActivity:LLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getName:L' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to class 'Lorg/xmlpull/v1/XmlPullParser;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getDepth:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'next:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getDepth:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getName:L' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to class 'Lorg/xmlpull/v1/XmlPullParserException;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method ':VLLL' in class 'Lorg/xmlpull/v1/XmlPullParserException;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseIntentFilter:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseMetaData:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to class 'Lorg/xmlpull/v1/XmlPullParser;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'parseMetaData:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'parseMetaData:VLLL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getAttributeValue:LLL' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'skipCurrentTag:VL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to class 'Lorg/xmlpull/v1/XmlPullParser;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'skipCurrentTag:VL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getDepth:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'skipCurrentTag:VL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'next:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'skipCurrentTag:VL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager;' refers to method 'getDepth:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'onInit:VLIL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$1;' refers to class 'Lorg/xmlpull/v1/XmlPullParser;' which is not loader class, this may cause crash when patch is loaded. FATAL: method 'onInit:VLIL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$1;' refers to method 'getEventType:I' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. FATAL: method 'onInit:VLIL' in loader class 'Lcom/tencent/tinker/loader/hotplug/IncrementComponentManager$1;' refers to method 'getName:L' in class 'Lorg/xmlpull/v1/XmlPullParser;' which is not in loader class, this may cause crash when patch is loaded. Check if loader classes in classes3.dex refer to any classes that is not in loader class patterns. Check if loader classes in classes4.dex refer to any classes that is not in loader class patterns. :app:tinkerPatchLishuaProRelease spend 13291ms`

企业微信截图_16242619108073

mjnhmd commented 3 years ago

我也是这样,解决了吗

xuetaotao commented 3 years ago

还没有,分析原因也是Tinker自己的一些类引用到的class,classloader没办法load,但是怎么解决暂时还是没有思路

------------------ 原始邮件 ------------------ 发件人: "Tencent/tinker" @.>; 发送时间: 2021年6月24日(星期四) 下午2:58 @.>; @.**@.>; 主题: Re: [Tencent/tinker] TinkerPatchException:调用了没有加载的类XmlPullParser导致打补丁包失败 (#1580)

我也是这样,解决了吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

srxffcc1 commented 2 years ago

看看自己的jdk版本 可能jdk版本太高了

yigepang commented 2 years ago

太恼火了,我也是这样的问题

xuetaotao commented 2 years ago

应该不是jdk版本的问题,我跑了两个项目都可以的,第三个项目同样的配置加上去才有这个问题。我看了源码,主要是1.9.14.6版本开始加了下面这个判断条件,才有了这个问题,但是怎么解决还是没有想通 image

shixiangyu commented 2 years ago

看一下项目是否开启R8混淆,R8会删除一些tinker中调用不明显的方法,导致这个问题

xFJournet commented 2 years ago

我也遇到了,然后查了下引用的jar和依赖库,发现有个jar包中存在XmlPullParser,把jar包里面的XmlPullParser删掉,重新生成jar,就解决了

xuetaotao commented 2 years ago

@shixiangyu 没有开启,这边都设置的false image

xuetaotao commented 2 years ago

@xFJournet 感谢提供思路,但是我查了下我代码里 XmlPullParser 的引用,压根没发现哪里有调用 它

xFJournet commented 2 years ago

@xFJournet 感谢提供思路,但是我查了下我代码里 XmlPullParser 的引用,压根没发现哪里有调用 它

查下是不是有引用的第三方库或者jar包里面用了,我的情况是引用的jar里面有

wangde commented 2 years ago

我也遇到了 我的方法是在tinker.gradle里把这两个类加了进去 dex{ loader = [ "org.xmlpull.v1.XmlPullParser", "org.xmlpull.v1.XmlPullParserException"] }

Lz-abc commented 2 years ago

我的处理方式 multidexkeep.pro 里加入 -keep class net.sf.kxml.*{;} -keep class org.xmlpull.v1.*{

(...); }
windfone commented 2 years ago

espresso_core 依赖注掉就好了

xuetaotao commented 2 years ago

我最后暂时先通过降低版本的方法解决了,降低版本到1.9.14.5,查源码发现报错的那里调用方法时1.9.14.6加上的;当然也可以自己改源码注释掉抛错信息;至于测试运行的结果暂时也没发现有啥问题。对于楼上的几种办法后面有空了再尝试一下,感谢大佬们了

xuetaotao commented 2 years ago

重新梳理分析了下问题,先说解决办法 1)去掉checkIfLoaderClassesReferToNonLoaderClasses()检查,即回退版本到1.9.14.5 2)在tinkerSupport闭包中配置dexLoader = ["org.xmlpull.v1.XmlPullParser", "org.xmlpull.v1.XmlPullParserException"],或者是在tinkerPatch闭包中配置dex{loader = ["org.xmlpull.v1.XmlPullParser", "org.xmlpull.v1.XmlPullParserException"]}

xuetaotao commented 2 years ago

下面开始分析 1)查看源码定位问题,问题抛出自com.tencent.tinker.build.decoder.DexDiffDecoder#checkIfLoaderClassesReferToNonLoaderClasses()方法 2)白话文描述下问题,com.tencent.tinker.loader.hotplug.IncrementComponentManager.AttrTranslator#onInit(Context, int, XmlPullParser)方法引用了org.xmlpull.v1.XmlPullParser类,但是后者不是已加载的类,可能会在加载补丁时导致崩溃。 3)分析源码找解决办法,问题源自 tinker-build/tinker-patch-lib 目录下的DexDiffDecoder.java,-->onAllPatchesEnd()方法-->checkIfLoaderClassesReferToNonLoaderClasses()方法-->isReferenceFromLoaderClassValid()方法-->if (!descOfClassesInApk.contains(refereeTypeDesc))这一行代码,这里为false,翻译一下就是,XmlPullParser包含在descOfClassesInApk集合中,导致抛出了这个问题。 4)确定解决思路,a)想办法去掉checkIfLoaderClassesReferToNonLoaderClasses()检查,即回退版本到1.9.14.5 b)copy一份源码手动注释掉异常抛出的代码部分,然后上传引用自己的(PASS) c)想办法让descOfClassesInApk集合中没有XmlPullParser类

xuetaotao commented 2 years ago

源码分析补充: 1)关于上面的checkIfLoaderClassesReferToNonLoaderClasses()方法做的事情,就是把oldApk文件通过smali工具库加载变成dex文件,然后通过getClasses()方法获取到所有class类的Set集合,接着遍历class类的集合,拿到每个class类中的属性Field集合和Method方法集合,依次遍历判断它们是否引用了没有load加载的类;然后遍历Method的过程中就出了问题。 2)关于上面的descOfClassesInApk集合中到底是什么东西?descOfClassesInApk集合是在DexDiffDecoder()构造函数中new出来的,在DexDiffDecoder#onAllPatchesStart()方法中做了clear(),在DexDiffDecoder#patch()-->collectClassesInDex()方法中做的赋值操作,官方的注释说明是Collect class descriptors here for further checking,具体做的事情呢,和前面一样通过smali工具库把oldApk加载变成dexFile,然后通过getClasses()方法获取到所有class类的Set集合并遍历,把它们的类描述Type添加到descOfClassesInApk集合中。嗯,这就是descOfClassesInApk中的存的东西。

xuetaotao commented 2 years ago

解释第二种解决办法的原理 在tinkerSupport闭包中配置dexLoader = ["org.xmlpull.v1.XmlPullParser", "org.xmlpull.v1.XmlPullParserException"],或者是在tinkerPatch闭包中配置dex{loader = ["org.xmlpull.v1.XmlPullParser", "org.xmlpull.v1.XmlPullParserException"]},这样配置定义了哪些类在加载补丁包的时候会用到。

这些类是通过Tinker无法修改的类,也是一定要放在main dex的类。这里需要定义的类有:1. 你自己定义的Application类; 2. Tinker库中用于加载补丁包的部分类,即com.tencent.tinker.loader.*; 3. 如果你自定义了TinkerLoader,需要将它以及它引用的所有类也加入loader中;4. 其他一些你不希望被更改的类,例如Sample中的BaseBuildInfo类。这里需要注意的是,这些类的直接引用类也需要加入到loader中。或者你需要将这个类变成非preverify。5. 使用1.7.6版本之后的gradle版本,参数1、2会自动填写。若使用newApk或者命令行版本编译,1、2依然需要手动填写。

因为我们在加载补丁包的时候用到了XmlPullParser和XmlPullParserException,而它们没有被加载,所以就会崩溃,那么我们在这里把它们加载到main dex中就可以了。

xuetaotao commented 2 years ago

最后,补充一个细节点,也给我自己造成了挺多麻烦,就是 tinker-support.gradle 中的两个插件配置意义 tinkerSupport:com.tencent.bugly.build.gradle.TinkerSupportExtension tinkerSupport(groovy.lang.Closure configuration) tinkerSupport插件中各个参数的意义:使用指南 - Bugly 文档 (qq.com) tinkerPatch:com.tencent.tinker.build.gradle.extension.TinkerPatchExtension tinkerPatch(groovy.lang.Closure configuration) tinkerPatch插件中各个参数的意义:Tinker 接入指南 · Tencent/tinker Wiki · GitHub 这两个插件配置的关系: tinkerSupport是bugly中的(看不到代码),tinkerPatch是tinker中的(代码开源) tinkerSupport中提供了tinkerPatch中各个配置参数的替代项,如前者的baseApk对应后者的oldApk参数,并且tinkerSupport中提供了overrideTinkerPatchConfiguration配置项,设置为true时,tinkerPatch配置不生效,所有的配置项以tinkerSupport中的配置为准。 如果是参考bugly上的热更新使用指南来接入apk的话,那么基本上都是使用的tinkerSupport,无需关心tinkerPatch

xuetaotao commented 2 years ago

补充一点,对于tinkerPatch中独有的配置项,如allowLoaderInAnyDex貌似tinkerSupport覆盖不了,可以在tinkerPatch中配置

主要是在解决这个问题中发现的: Warning:ignoreWarning is true, but we found loader classes are found in old secondary dex. Found classes: {Lcom/tencent/tinker/loader/hotplug/ActivityStubs$SIStub_01; ,Lcom/tencent/tinker/loader/shareutil/ShareResPatchInfo;, Lcom/tencent/tinker/loader/SystemClassLoaderAdder$V23;,

解决办法是:在tinkerpatch闭包下添加:allowLoaderInAnyDex = true 和 removeLoaderForAllDex = true