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

1.9.13.2升级到 1.9.14.7 遇到问题:Unable to instantiate application #1439

Closed 1136346879 closed 4 years ago

1136346879 commented 4 years ago

Issue/提问须知

在提交issue之前,我们应该先查询是否已经有相关的issue以及常见问题。提交issue时,我们需要写明issue的原因,以及编译或运行过程的日志(加载进程以及Patch进程)。issue需要以下面的格式:


异常类型:app运行时异常

手机型号:如:vivo x21A

手机系统版本:如:Android 9.0

tinker版本:1.9.14.7

gradle版本:3.5.3

是否使用热更新SDK: no

系统:如:Mac

堆栈/日志:
    java.lang.RuntimeException: Unable to instantiate application com.xfs.fsyuncai.logic.TinkerFSYCApplication: java.lang.ClassNotFoundException: Didn't find class "com.xfs.fsyuncai.logic.TinkerFSYCApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.xfs.fsyuncai-d-cOAlSRpAy0u59iTxeiHA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xfs.fsyuncai-d-cOAlSRpAy0u59iTxeiHA==/lib/arm64, /data/app/com.xfs.fsyuncai-d-cOAlSRpAy0u59iTxeiHA==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1084)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6171)
        at android.app.ActivityThread.access$1200(ActivityThread.java:236)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1851)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7042)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:868)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xfs.fsyuncai.logic.TinkerFSYCApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.xfs.fsyuncai-d-cOAlSRpAy0u59iTxeiHA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xfs.fsyuncai-d-cOAlSRpAy0u59iTxeiHA==/lib/arm64, /data/app/com.xfs.fsyuncai-d-cOAlSRpAy0u59iTxeiHA==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
        at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:47)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1124)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1076)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6171) 
        at android.app.ActivityThread.access$1200(ActivityThread.java:236) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1851) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:224) 
        at android.app.ActivityThread.main(ActivityThread.java:7042) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:868) 
2020-07-31 09:44:41.881 1582-10281/? E/ActivityManager: Sending non-protected broadcast com.vivo.applicationbehaviorengine.power.refreshList from system 2275:com.vivo.abe/1000 pkg com.vivo.abe

您好: 我们的app已经 在使用tinker,现在继承的 是 1.9.13.2  版本 没有问题  已经在线上使用中
            我们这边准备升级到最新版本  1.9.14.7,然后按照github上升级集成,报的这个错误。打开App 找不到 这个application
           应该是分包的问题,是不是咱们  1.9.14.7 对集成有什么特殊操作还是 分包有什么逻辑添加。

下方是我项目中的代码配置:
gradle.properties下的配置添加

tinkerEnable=true
org.gradle.parallel=true
org.gradle.daemon=true
TINKER_VERSION=1.9.14.7
android.enableR8.libraries = false
android.enableR8 = false
android.enableD8.desugaring=false
allowLoaderInAnyDex=true
removeLoaderForAllDex=true
isProtectedApp=true

项目的build.gradle
    dependencies {
        //noinspection GradleDependency
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        classpath "com.tencent.tinker:tinker-patch-gradle-plugin:${TINKER_VERSION}"
}
app 下的 gradle
//apply tinker插件
apply plugin: 'com.tencent.tinker.patch'

dependencies {
  //tinker核心sdk库     参与编译与打包
    //noinspection GradleDependency
    implementation("com.tencent.tinker:tinker-android-lib:${TINKER_VERSION}") { changing = true }

    implementation("com.tencent.tinker:tinker-android-loader:${TINKER_VERSION}") { changing = true }

    annotationProcessor("com.tencent.tinker:tinker-android-anno-support:${TINKER_VERSION}") { changing = true }
    compileOnly("com.tencent.tinker:tinker-android-anno-support:${TINKER_VERSION}") { changing = true }
}
1136346879 commented 4 years ago

我这边用 gtihub上的demo 用1.9.14.7 出现的是一样的问题。麻烦看看是什么问题导致的!!! 谢谢大佬 ![Uploading image.png…]()

1136346879 commented 4 years ago

github demo运行错误堆栈信息:
Process: tinker.sample.android, PID: 8292 java.lang.RuntimeException: Unable to instantiate application tinker.sample.android.app.SampleApplication: java.lang.ClassNotFoundException: Didn't find class "tinker.sample.android.app.SampleApplication" on path: DexPathList[[zip file "/data/app/tinker.sample.android-13gicSoD7HUZMN-KSESMIw==/base.apk"],nativeLibraryDirectories=[/data/app/tinker.sample.android-13gicSoD7HUZMN-KSESMIw==/lib/arm64, /system/lib64]] at android.app.LoadedApk.makeApplication(LoadedApk.java:1084) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6171) at android.app.ActivityThread.access$1200(ActivityThread.java:236) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1851) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7042) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:868) Caused by: java.lang.ClassNotFoundException: Didn't find class "tinker.sample.android.app.SampleApplication" on path: DexPathList[[zip file "/data/app/tinker.sample.android-13gicSoD7HUZMN-KSESMIw==/base.apk"],nativeLibraryDirectories=[/data/app/tinker.sample.android-13gicSoD7HUZMN-KSESMIw==/lib/arm64, /system/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50) at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:47) at android.app.Instrumentation.newApplication(Instrumentation.java:1124) at android.app.LoadedApk.makeApplication(LoadedApk.java:1076) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6171)  at android.app.ActivityThread.access$1200(ActivityThread.java:236)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1851)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:224)  at android.app.ActivityThread.main(ActivityThread.java:7042)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:868) 

youxiachai commented 4 years ago

把这个 annotationProcessor("com.tencent.tinker:tinker-android-anno-support:${TINKER_VERSION}") { changing = true } 改成 annotationProcessor("com.tencent.tinker:tinker-android-anno:${TINKER_VERSION}") { changing = true }

不要带support 不然生成不了那个SampleApplication的类

1136346879 commented 4 years ago

可以了 谢谢大佬