Tinker: 使用tinker1.9.9运行异常

Created on 9 Oct 2018  ·  15Comments  ·  Source: Tencent/tinker

异常类型:app运行时异常

手机型号:oppo a83&华为p10

手机系统版本:android7.1&android8.0

tinker版本:1.9.9

gradle版本:3.1.4

是否使用热更新SDK: Bugly SDK

系统:win10

堆栈/日志:
10-09 10:22:05.288 29341-29341/? E/Tinker.UncaughtHandler: TinkerUncaughtHandler catch exception:java.lang.RuntimeException: Unable to instantiate application com.xlceb.fbike.app.App: com.tencent.tinker.loader.TinkerRuntimeException: Tinker Exception:null
at android.app.LoadedApk.makeApplication(LoadedApk.java:862)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5903)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: com.tencent.tinker.loader.TinkerRuntimeException: Tinker Exception:null
at com.tencent.tinker.loader.app.TinkerApplication.onBaseContextAttached(SourceFile:144)
at com.tencent.tinker.loader.app.TinkerApplication.attachBaseContext(SourceFile:152)
at android.app.Application.attach(Application.java:198)
at android.app.Instrumentation.newApplication(Instrumentation.java:1008)
at android.app.Instrumentation.newApplication(Instrumentation.java:992)
at android.app.LoadedApk.makeApplication(LoadedApk.java:856)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5903) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:232) 
at android.app.ActivityThread.main(ActivityThread.java:6802) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.tencent.tinker.loader.app.TinkerApplication.onBaseContextAttached(SourceFile:136)
at com.tencent.tinker.loader.app.TinkerApplication.attachBaseContext(SourceFile:152) 
at android.app.Application.attach(Application.java:198) 
at android.app.Instrumentation.newApplication(Instrumentation.java:1008) 
at android.app.Instrumentation.newApplication(Instrumentation.java:992) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:856) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5903) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:232) 
at android.app.ActivityThread.main(ActivityThread.java:6802) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) 
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/tencent/tinker/loader/app/ApplicationLike;
at com.tencent.bugly.beta.tinker.TinkerManager.installTinker(SourceFile:176)
at com.tencent.bugly.beta.Beta.installTinker(SourceFile:981)
at com.xlceb.fbike.app.ApplicationLike.onBaseContextAttached(SourceFile:142)
at java.lang.reflect.Method.invoke(Native Method) 
at com.tencent.tinker.loader.app.TinkerApplication.onBaseContextAttached(SourceFile:136) 
at com.tencent.tinker.loader.app.TinkerApplication.attachBaseContext(SourceFile:152) 
at android.app.Application.attach(Application.java:198) 
at android.app.Instrumentation.newApplication(Instrumentation.java:1008) 
at android.app.Instrumentation.newApplication(Instrumentation.java:992) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:856) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5903) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:232) 
at android.app.ActivityThread.main(ActivityThread.java:6802) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.tencent.tinker.loader.app.ApplicationLike" on path: DexPathList[[zip file "/data/app/com.xlceb.fbike-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xlceb.fbike-1/lib/arm, /data/app/com.xlceb.fbike-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.tencent.bugly.beta.tinker.TinkerManager.installTinker(SourceFile:176) 
at com.tencent.bugly.beta.Beta.installTinker(SourceFile:981) 
at com.xlceb.fbike.app.ApplicationLike.onBaseContextAttached(SourceFile:142) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.tencent.tinker.loader.app.TinkerApplication.onBaseContextAttached(SourceFile:136) 
at com.tencent.tinker.loader.app.TinkerApplication.attachBaseContext(SourceFile:152) 
at android.app.Application.attach(Application.java:198) 
at android.app.Instrumentation.newApplication(Instrumentation.java:1008) 
at android.app.Instrumentation.newApplication(Instrumentation.java:992) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:856) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5903) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:232) 
at android.app.ActivityThread.main(ActivityThread.java:6802) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) 

Most helpful comment

Bugly更新到1.3.6 tinker-support更新到1.1.5 就好了 参考(https://github.com/BuglyDevTeam/Bugly-Android-Demo)

All 15 comments

我也遇到了,有没有办法解决

com.tencent.tinker.android.dex.DexException: com.tencent.tinker.android.dex.DexException: Unexpected magic: [100, 101, 120, 10, 48, 51, 55, 0]
同样的环境,我打补丁包 出现这个,大神遇到过吗

tinker升级到1.9.9之后,ApplicationLike和ApplicationLifeCycle这两个类的包名要改成com.tencent.tinker.entry

@dvlp-org
你用了d8和java7以上的新特性?(lambda、try with resource之类的),这样的话就会打出037格式的dex,tinker暂时还不支持这种新格式的dex哇

Bugly更新到1.3.6 tinker-support更新到1.1.5 就好了 参考(https://github.com/BuglyDevTeam/Bugly-Android-Demo)

@tomystang 是不是项目中有使用java8中的lambda语法,就无法使用tinker?

dex格式怎么查看呀,希望作者尽快支持下D8,设置成false以及告警后续版本很快就会取消

我也遇到了,有没有办法解决

是不支持java8吗?

请问,现在支持 JDK1.8了吗

@tomystang
我这里报com.tencent.tinker.android.dex.DexException: Unexpected magic: [100, 101, 120, 10, 48, 51, 56, 0]

看了下tinker好像只支持到035
int var3 = DexFormat.magicToApi(var2);
if (var3 != 13) {
throw new DexException("Unexpected magic: " + Arrays.toString(var2));
}

public static int magicToApi(byte[] magic) {
if (magic.length != 8) {
return -1;
} else if (magic[0] == 100 && magic[1] == 101 && magic[2] == 120 && magic[3] == 10 && magic[7] == 0) {
String var1 = "" + (char)magic[4] + (char)magic[5] + (char)magic[6];
if (var1.equals("036")) {
return 14;
} else {
return var1.equals("035") ? 13 : -1;
}
} else {
return -1;
}
}

我这边读到的dex格式是038, 已经配置使用java 1.6编译, 并且关闭了D8, 还有什么会影响到这个dex格式啊? 如何能降035?

dex格式 应该只是跟你 App 的 minSdkVersion 有关。 如果你使用 as 的 run 编译,就应该会跟你的连接的机器的系统版本。

@hlllmr1314 有解决吗 我现在也是这个问题 我这里报com.tencent.tinker.android.dex.DexException: Unexpected magic: [100, 101, 120, 10, 48, 51, 56, 0]

@qwerwen 如DimRed所说,DexException和minSDKVersion有关 小于23是35 24对应36 25对应37 26对应38

dex格式 应该只是跟你 App 的 minSdkVersion 有关。 如果你使用 as 的 run 编译,就应该会跟你的连接的机器的系统版本。

打出来的dex和as的run会有关系吗?????

Was this page helpful?
0 / 5 - 0 ratings