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

时间:2019-06-23 12:23:32

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

最近,由于无法运行react-native run-android,我已迁移到AndroidX,它建议我将tools:replace="android:appComponentFactory"添加到<application>文件的AndroidManifest.xml标记中。因此,经过大量搜索后,我被说服了迁移到AndroidX。除了在AndoirdManifest文件中进行一些更改之外,我还在 gradle.properties 中添加了以下两行: 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 如果您需要了解有关我的问题的更多信息才能回答我的问题,请问我。

1 个答案:

答案 0 :(得分:0)

单击“ AndroidManifest.xml”,在文件页面底部看到“文本”和“合并的清单”,然后单击“合并的清单”->搜索“ android.support.v4.content.FileProvider”,然后使用“ androidx.core.content.FileProvider”对其进行更改

就这样,确切的解决方法。

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