安卓解决java.lang.RuntimeException: Unable to get provider com.blankj.utilcode.util.Utils$FileProvider

版权声明:转载需得到本人同意,私自转载违法 https://blog.csdn.net/haojiagou/article/details/84918005

在其他手机上运行的好好的,换了一个手机运行,直接打不开,报错:

 java.lang.RuntimeException: Unable to get provider com.blankj.utilcode.util.Utils$FileProvider4UtilCode: java.lang.ClassNotFoundException: Didn't find class "com.blankj.utilcode.util.Utils$FileProvider4UtilCode" on path: DexPathList[[zip file "/data/app/zj.it.bhne.pwqgc.pwqgc-1.apk"],nativeLibraryDirectories=[/data/app-lib/zj.it.bhne.pwqgc.pwqgc-1, /vendor/lib, /system/lib]]

网上搜了下,发现是MultiDex未初始化的问题,需要在Gradle中修改配置文件,并在application中进行初始化。代码如下:

 defaultConfig {
        multiDexEnabled true
    }
override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(base)
    }

java中复制下面的。

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

猜你喜欢

转载自blog.csdn.net/haojiagou/article/details/84918005