安卓解決java.lang.RuntimeException: Unable to get provider com.blankj.utilcode.util.Utils$FileProvider
阿新 • • 發佈:2018-12-09
在其他手機上執行的好好的,換了一個手機執行,直接打不開,報錯:
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); }