简体   繁体   中英

app crashes: E/AndroidRuntime + android.support.v4.content.FileProvider class not found

Recently, I've migrated to AndroidX because I couldn't run react-native run-android and it suggested me to add tools:replace="android:appComponentFactory" to my <application> tag in my AndroidManifest.xml file. so after searching a lot I was somehow convinced to migrate to AndroidX. beside making some changes in AndoirdManifest file I added the 2 below lines to my gradle.properties : android.useAndroidX=true android.enableJetifier=true

... also I had to make some changes in 7 packages in node_modules to be compatible with androidx. and finally I could BUILD SUCCESSFUL, but now the problem is that my app crashes. and in logcat I have the err that E AndroidRuntime: java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: .... in some searches I found out that maybe making some changes in <provider> in AnroidManifest file would be the answer but the truth is that I don't have any provider tags in my AndroidManifest file. so there again I stuck and don't know how to solve this issue

Extra info: ((Packages that have been changed)):

`|__ lottie-react-native
 |__ react-native-firebase
 |__ react-native-gesture-handler
 |__ @cedarstudios
    `|__ react-native-mapbox-gl
 |__ react-native-maps
 |__ react-native-push-notifications
 |__ rn-fetch-blob

What I've tried:

I added provider then again new errors occur. then again I removed that

Part of my AndroidManifest.xml file:

<application
      tools:replace="android:appComponentFactory"
      android:appComponentFactory="androidx.core.app.CoreComponentFactory"
      android:name=".MainApplication"
      android:allowBackup="false"
      android:fullBackupContent="false"
      android:label="@string/app_name"
      android:supportsRtl="false"
      android:icon="@mipmap/ic_launcher"
      android:largeHeap="true"
      android:theme="@style/AppTheme">

Part of the logcat error:

54565:06-23 16:00:09.544 22227 22227 E AndroidRuntime: Process: com.myAppName, PID: 22227
54566:06-23 16:00:09.544 22227 22227 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 "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.myAppName-YLgUAaSaaK5LGP1d0LJLSw==/base.apk"],nativeLibraryDirectories=[/data/app/com.myAppName-YLgUAaSaaK5LGP1d0LJLSw==/lib/arm, /data/app/com.myAppName-YLgUAaSaaK5LGP1d0LJLSw==/base.apk!/lib/armeabi-v7a, /system/lib]]
54578:06-23 16:00:09.544 22227 22227 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.myAppName-YLgUAaSaaK5LGP1d0LJLSw==/base.apk"],nativeLibraryDirectories=[/data/app/com.myAppName-YLgUAaSaaK5LGP1d0LJLSw==/lib/arm, /data/app/com.myAppName-YLgUAaSaaK5LGP1d0LJLSw==/base.apk!/lib/armeabi-v7a, /system/lib]]

what I expect is to run my app successfully on my phone without crashing

PM if you need to know more information about my issue in order to answer my question, ask me please.

Click to AndroidManifest.xml look at the bottom of the files page you gonna see "Text" and "Merged Manifes" then click to "Merged Manifest" -> Search for "android.support.v4.content.FileProvider" then change it with "androidx.core.content.FileProvider"

Thats it, exact solution.

Also change your android.support.v4 with androidx version libraries. Please search for new androidx versions of android libraris

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM