當我在模擬器上運行應用程序時,它總是在第一次嘗試時運行。但是,當應用程序已經安裝在模擬器上時,通常會在應用程序啓動過程中導致崩潰。 此行爲在Android Studio 2.0中開始發生。 它不會在設備上發生,因此它不是很重要,但只是很煩人,因爲我總是需要在安裝新版本之前從模擬器中刪除應用程序。自從FileProvider Class找不到之後,應用程序崩潰後重新安裝
因爲我完全不知道是什麼原因導致這個問題,在研究期間找不到類似的問題,所以我希望有人能幫助我。
錯誤消息:
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
文件提供的清單:
<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>
嗨每一個我在離子發展期間遇到fileprovider的問題,因爲我們使用android作爲平臺與離子在那裏我們使用離子建設android構建項目,所以android.json也是其中一個正在閱讀的文件構建過程..我觀察到android.json中的「/ manifest」:[]在使用帶有FileProvider類的使用權限標記時產生了一個錯誤的行,這個行在接近8到10個小時的持續性strasck之後一次又一次地拋出錯誤溢出和比較文件與超越比較我發現這個問題.. – Dhana
我遇到了同樣的問題。但沒有找到任何解決方案 – ashraful