androidStudio分包引起的系统崩溃,报错ClassNotFoundException: Didn't find class "XXXView" on path: DexPath../.apk

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xzytl60937234/article/details/82743675

按照网上查询的方法,删除了build文件夹以后重新clean project,并没有解决问题。

1.androidStudio编译时生成的 debug.apk文件,在有的手机上安装成功,点击图标直接退出,查阅错误信息:

ClassNotFoundException: Didn’t find class “XXXX” on path: DexPathList[[zip file “/data/app/[包名]-1.apk”],nativeLibraryDirectories=[/data/app-lib/[包名]-1, /vendor/lib, /system/lib]].

项目运行闪退,在安卓6.0和5.0的手机上均没有问题,但是在华为手机4.2.2 手机上出现了闪退,查阅了许多资料,是因为MultiDex分包引起的,但是没有初始化的原因。

查看项目中是否采用了MultiDex分包:

这里写图片描述

处理:

1、Gradle配置(app build.gradle)

  // 多dex配置
    compile 'com.android.support:multidex:+'

     defaultConfig {
      //方法数超限时分割dex
        multiDexEnabled true
     }

2、在Application类中复写attachBaseContext方法添加初始化代码

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(base);

}

猜你喜欢

转载自blog.csdn.net/xzytl60937234/article/details/82743675