AndroidX ClassNotFound Exception: “android.support. v4.content .FileProvider”
This was an issue that was occurring after the migrating with new Androidx migration. The root cause was the android.support.v4.content.FileProvider
was not provided in the latest android support library.
To debug this error you will have to see the adb log
with the command
adb logcat
The issue will be visible for you as following in the log
12-19 09:29:21.936 20340 20340 E AndroidRuntime: 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.foo-ZEEUwKWVlwMF6G0KnwUxrA==/base.apk"],nativeLibraryDirectories=[/data/app/com.foo-ZEEUwKWVlwMF6G0KnwUxrA==/lib/x86, /data/app/com.foo-ZEEUwKWVlwMF6G0KnwUxrA==/base.apk!/lib/x8
6, /system/lib]]
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6396)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.app.ActivityThread.access$1100(ActivityThread.java:199)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6669)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
12-19 09:29:21.936 20340 20340 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
You can get around this issue by finding the relevant code line from the AndroidManifest.xml
file
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
First, comment out this and see whether that error is gone from your app. Then if it’s good, you can remove it forever and run the project.
Checkout following on how to setup FCM push notifications with react native app.