Unable to get provider android.support.v4.content.FileProvider
今天在项目中碰到一个很棘手的问题,在一款api 19的oppo 手机上运行部了项目,一直报错 ,如下:
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip
file "/data/app/com.zyjr.emergencylending-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.zyjr.emergencylending-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4892)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4484)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4424)
at android.app.ActivityThread.access$1500(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5120)
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:818)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.zyjr.emergencylending-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.zyjr.emergencylending-1,
/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:4877)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4484)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4424)
at android.app.ActivityThread.access$1500(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5120)
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:818)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
在网上找了好多资料,找了好久,终于解决了,希望能帮到需要的人,也帮自己记录一下!
解决方法:
可能是添加MultiDex分包,但未初始化的原因,在Application中重写attachBaseContext函数,对MultiDex初始化即可。
1)首先修改Gradle配置文件,启用MultiDex并包含MultiDex支持:
defaultConfig {
multiDexEnabled true
}
2)修改BaseApplication,重写attachBaseContext方法 @Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
上一篇: android 封装权限
推荐阅读
-
Unable to get the CMake version located at
-
linux系统启动weblogic受管服务器报unable to get file lock, will ret_daring的解决
-
java.lang.RuntimeException: Unable to get provider android.provider.DocumentsProvider: java.lang.Ins
-
git中的SSL certificate problem: unable to get local issuer certificate错误的解决办法
-
docker 容器内apt-get install 报E: Unable to locate package xxx问题解决
-
Zynq linux加载axi_dma驱动报错 axidma: axidma_dma.c: axidma_request_channels: 651: Unable to get slave chan
-
file_get_contents获取https出现这个错误Unable to find the wrapper “https” – did
-
Unable to get provider android.support.v4.content.FileProvider
-
Unable to get the CMake version located at
-
执行python时,使用fiddler代理,提示Unable to get local issuer certificate when using requests in python