在模拟器上重新安装后,由于找不到FileProvider Class,应用程序崩溃 [英] App crashes after reinstall on emulator since FileProvider Class was not found

查看:58
本文介绍了在模拟器上重新安装后,由于找不到FileProvider Class,应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在模拟器上运行该应用程序时,它总是可以在第一次尝试时运行.但是,当应用程序已经安装在模拟器上时,通常会在应用程序启动期间导致崩溃. Android Studio 2.0开始出现此现象. 它不会在设备上发生,因此它并不是那么重要,而只是令人讨厌,因为在安装新版本之前,我总是需要从模拟器中删除该应用程序.

When I run the app on the emulator it always works on the first try. But when the app is already installed on the emulator it often results in a crash during the start of the app. This behavior started to occur with Android Studio 2.0. It does not occur on devices, therefore it is not so important but only annoying since I always need to delete the app from the emulator before installing a new version.

由于我完全不知道是什么原因导致了这个问题,并且在研究过程中找不到类似的问题,所以希望有人可以帮助我.

Since I have absolutely no idea what causes this issue and can't find similar issues during research, I hope that somebody can help me.

错误消息:

08-25 09:55:35.023 4214-4214/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mls.Search.Abbott, PID: 4214
    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.mls.Search.Abbott-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mls.Search.Abbott-2/lib/x86, /data/app/com.mls.Search.Abbott-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
        at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
        at android.app.ActivityThread.-wrap1(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.mls.Search.Abbott-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mls.Search.Abbott-2/lib/x86, /data/app/com.mls.Search.Abbott-2/base.apk!/lib/x86, /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)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5141)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) 
        at android.app.ActivityThread.-wrap1(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
    Suppressed: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[dex file "/data/data/com.mls.Search.Abbott/files/instant-run/dex/slice-slice_3-classes.dex"],nativeLibraryDirectories=[/data/app/com.mls.Search.Abbott-2/lib/x86, /data/app/com.mls.Search.Abbott-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
        at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
              ... 12 more
            Suppressed: java.lang.ClassNotFoundException: android.support.v4.content.FileProvider
        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)
                ... 13 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

清单中的文件提供程序:

File Provider in Manifest:

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/filepaths" />
</provider>

推荐答案

如果您使用的是 androidx 库,请在 AndroidManifest.xml 中进行以下更改:

If you are using androidx libraries, in AndroidManifest.xml, change this:

android:name="android.support.v4.content.FileProvider"

对此:

android:name="androidx.core.content.FileProvider"

这篇关于在模拟器上重新安装后,由于找不到FileProvider Class,应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆