美文网首页
MultiDex Support库引发的NoClassDefFo

MultiDex Support库引发的NoClassDefFo

作者: 小楠总 | 来源:发表于2020-03-25 11:16 被阅读0次

    今天在低端机器上面遇到一个奇怪的启动闪退:

    Process: com.flyme.videoclips
    Flags: 0xa83e46
    Package: com.flyme.videoclips v2007000 (2.7.0)
    Build: Meizu/meizu_m3note/m3:5.1/LMY47I/1532423771:user/release-keys
    
    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/multidex/MultiDex;
        at com.flyme.videoclips.VideoClipsApplication.attachBaseContext(VideoClipsApplication.java:71)
        at android.app.Application.attach(Application.java:197)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1004)
        at android.app.Instrumentation.newApplication(Instrumentation.java:988)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:607)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5111)
        at android.app.ActivityThread.access$1600(ActivityThread.java:187)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:194)
        at android.app.ActivityThread.main(ActivityThread.java:5914)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1127)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:893)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDex" on path: DexPathList[[zip file "/data/app/com.flyme.videoclips-2/base.apk"],nativeLibraryDirectories=[/data/app/com.flyme.videoclips-2/lib/arm, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        ... 15 more
        Suppressed: java.lang.ClassNotFoundException: android.support.multidex.MultiDex
            at java.lang.Class.classForName(Native Method)
            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 16 more
        Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
    

    研究了一下,以前魅族的老机型会做dex预优化,Debug编译出来的包会有比较多的dex文件,Release编译出来的包只有3个dex文件。老机型在安装Debug包后会闪退(注意Android Studio默认直接编译运行的也是Debug包),对比图如下:

    Debug包 Release包

    相关文章

      网友评论

          本文标题:MultiDex Support库引发的NoClassDefFo

          本文链接:https://www.haomeiwen.com/subject/zldtuhtx.html