react-native - 应用程序崩溃 : E/AndroidRuntime + android. support.v4.content.FileProvider 类未找到

标签 react-native crash androidx android-fileprovider android-runtime

最近,我迁移到 AndroidX,因为我无法运行 react-native run-android,它建议我将 tools:replace="android:appComponentFactory" 添加到我的 <application> 文件中的 AndroidManifest.xml 标记中。所以在搜索了很多之后,我以某种方式被说服迁移到 AndroidX。除了在 AndoirdManifest 文件中进行一些更改之外,我还在我的 gradle.properties 中添加了以下 2 行: android.useAndroidX=true android.enableJetifier=true
...我还必须对 node_modules 中的 7 个包进行一些更改以与 androidx 兼容。最后我可以建立成功,但现在的问题是我的应用程序崩溃了。在logcat中我犯了错误E AndroidRuntime: java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: ....在一些搜索中,我发现可能在 AnroidManifest 文件中对 <provider> 进行一些更改将是答案,但事实是我的 AndroidManifest 文件中没有任何提供程序标签。所以我又卡住了,不知道如何解决这个问题

额外信息:((已更改的包)):

`|__ 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

我试过的:

我添加了提供程序,然后又出现了新的错误。然后我又删除了那个

我的 AndroidManifest.xml 文件的一部分:
<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">

logcat 错误的一部分:
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]]

我期望的是在我的手机上成功运行我的应用程序而不会崩溃

PM 如果您需要了解有关我的问题的更多信息以回答我的问题,请询问我。

最佳答案

单击 AndroidManifest.xml 查看文件页面底部,您将看到“文本”和“合并 list ”,然后单击“合并 list ”->搜索“android.support.v4.content.FileProvider”,然后将其更改为“androidx.core.content.FileProvider”

就是这样,确切的解决方案。

还使用 androidx 版本库更改您的 android.support.v4。请搜索新的androidx版本的android libraris

关于react-native - 应用程序崩溃 : E/AndroidRuntime + android. support.v4.content.FileProvider 类未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56723831/

相关文章:

javascript - 开 Jest + 火力地堡 : TypeError: Cannot read property 'defineProperties' of undefined

React-native抽屉导航器不显示

ios - UIApplicationMain 的 EXC_BAD_ACCESS - 如何解释此回溯?

linux - 速率高时检测到 httperf 缓冲区溢出

ios - 启动时应用程序崩溃

Androidx 模块,android :attr/ttcIndex & android:attr/fontVariationSettings not found

android - 主要 Activity 中 Unresolved 功能引用

android - TextInput 光标移动到显示/隐藏密码的开头

javascript - 是否可以在 React Native 中从 javascript 字符串动态构造 JSX?

androidx AppBarLayout AppBar top margin问题