Tinker: but we found loader classes are found in old secondary dex.

Created on 19 Jul 2019  ·  10Comments  ·  Source: Tencent/tinker

classpath "com.tencent.bugly:tinker-support:1.1.5"
classpath 'com.android.tools.build:gradle:3.2.1'
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

compile "com.android.support:multidex:1.0.3"
api 'com.tencent.bugly:crashreport_upgrade:1.3.6'
api 'com.tencent.tinker:tinker-android-lib:1.9.9'
api 'com.tencent.bugly:nativecrashreport:3.7.1'

现在发现tinker相关的文件都在classes2.dex中而不是在classes.dex中,抓耳挠腮不知道如何解决,请大神们给出一些解决思路。

bug duplicate

All 10 comments

遇到同样的问题

同样的问题,更新了版本还是一样,怀疑是 Gradle 版本太新的问题,看了很多 Issues 他们的 Gradle 版本都是比较旧的版本.而且新版的 Tinker 打包的时候不会生成 tinker_multidexkeep.pro 这个文件,不清楚是不是跟这个也有关系

同样遇到这样的问题, 使用旧版的gradle也出现过此问题, 以前也有提过此类问题的, 但是从没人回答过

Version

  • tinker: 1.9.13.2
  • gradle: 5.5.1
  • android gradle plugin: 3.4.2

app/build.gradle Config:

android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 21
        multiDexEnabled true
        multiDexKeepProguard file("./tinker_multidexkeep.pro")

tinker_multidexkeep.pro:


#tinker multidex keep patterns:
-keep public class * implements com.tencent.tinker.loader.app.ApplicationLifeCycle {
    <init>(...);
    void onBaseContextAttached(android.content.Context);
}

-keep public class * extends com.tencent.tinker.loader.TinkerLoader {
    <init>(...);
}

-keep public class * extends android.app.Application {
     <init>();
     void attachBaseContext(android.content.Context);
}

-keep class com.tencent.tinker.loader.TinkerTestAndroidNClassLoader {
    <init>(...);
}

#your dex.loader patterns here
-keep class com.xxx.XXTinkerApplication {
    <init>(...);
}

-keep class com.tencent.tinker.loader.** {
    <init>(...);
}

TinkerPatchException:

Check for loader classes in dex: classes3.dex
Check for loader classes in dex: classes2.dex
loader classes are found in old secondary dex. Found classes:{com.xxx.XXTinkerApplication}
at com.tencent.tinker.build.util.ExcludedClassModifiedChecker.checkIfExcludedClassWasModifiedInNewDex(ExcludedClassModifiedChecker.java:193)
        at com.tencent.tinker.build.decoder.DexDiffDecoder.patch(DexDiffDecoder.java:136)
        at com.tencent.tinker.build.decoder.UniqueDexDiffDecoder.patch(UniqueDexDiffDecoder.java:39)
        at com.tencent.tinker.build.decoder.ApkDecoder$ApkFilesVisitor.visitFile(ApkDecoder.java:176)

原因参考 #1084
规避方法:升级到1.9.14后开启allowLoaderInAnyDexremoveLoaderForAllDex这两个选项即可。

@tomystang
我们现在通过bugly间接使用tinker,bugly目前最新使用的是1.9.13的的版本。
针对1.9.13及以下的版本是否有相关兼容方法呢?

@tomystang 1.9.14后开启allowLoaderInAnyDex和removeLoaderForAllDex这两个选项在哪开启? 文档里有说明么?

removeLoaderForAllDex

原因参考 #1084
规避方法:升级到1.9.14后开启allowLoaderInAnyDexremoveLoaderForAllDex这两个选项即可。

请问在哪里配置 allowLoaderInAnyDex 和 removeLoaderForAllDex?

removeLoaderForAllDex

具体在哪里配置 有人知道吗?

removeLoaderForAllDex

具体在哪里配置 有人知道吗?

找到解决方法了 目前使用的版本是最新版本可以在tinkerPatch{}的文件下新增allowLoaderInAnyDex =true 和 removeLoaderForAllDex = true 和ignoreWarning放在同级 亲测minSDK =21可用

Was this page helpful?
0 / 5 - 0 ratings