升级到Android Studio 3.0 第三方包 初始化crash,如xutils, universal-image-loader, RongIM等

作者: android 发布时间: 2017-11-14 浏览: 1458 次 编辑

今天在开发的时候,从Android Studio2.3 升级到 Android Studio3.0的时候,在低版本机器(如:android4.4 api=19)初始化第三方包的时候,crash, 如xutils, universal-image-loader, RongIM等,但是在5.0 之后都可以正常运行;如下的错误日志:

java.lang.NoClassDefFoundError: com.nostra13.universalimageloader.core.assist.QueueProcessingType

或者

java.lang.NoClassDefFoundError: org.xutils.common.task.TaskControllerImpl


11-14 14:18:48.361 6769-6769/? E/memtrack: Couldn't load memtrack module (No such file or directory)
11-14 14:18:48.361 6769-6769/? E/android.os.Debug: failed to load memtrack module: -2
11-14 14:18:49.001 6783-6783/? E/memtrack: Couldn't load memtrack module (No such file or directory)
11-14 14:18:49.001 6783-6783/? E/android.os.Debug: failed to load memtrack module: -2
11-14 14:18:49.461 6793-6793/com.zuihuibao E/AndroidRuntime: FATAL EXCEPTION: main
                                                             Process: com.zuihuibao, PID: 6793
                                                             java.lang.NoClassDefFoundError: org.xutils.common.task.TaskControllerImpl
                                                                 at org.xutils.x$Ext.init(x.java:90)
                                                                 at com.zuihuibao.ZHBApplication.initXUtils(ZHBApplication.java:108)
                                                                 at com.zuihuibao.ZHBApplication.onCreate(ZHBApplication.java:71)
                                                                 at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
                                                                 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
                                                                 at android.app.ActivityThread.access$1500(ActivityThread.java:135)
                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                 at android.os.Looper.loop(Looper.java:136)
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5017)
                                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                                 at java.lang.reflect.Method.invoke(Method.java:515)
                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                 at dalvik.system.NativeStart.main(Native Method)
11-14 14:18:50.251 1918-1918/com.android.launcher E/EGL_emulation: tid 1918: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH)

网上的资料很少,最后花了大半天时间,终于问题解决了:

因为产生此问题的原型是由于在android stuido 中进行了分包的处理,分包处理后把项目application继承的父类改为MultiDexApplication 即可。

仅供大家参考