最近,我因为无法运行react-native run-android
而迁移到AndroidX,它建议我将tools:replace="android:appComponentFactory"
添加到<application>
文件中的AndroidManifest.xml
标签中。因此,经过大量搜索后,我被说服了迁移到AndroidX。除了在AndoirdManifest文件中进行一些更改外,我还在gradle.properties中添加了以下两行:android.useAndroidX=trueandroid.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]]
我期望的是在手机上成功运行我的应用程序而不会崩溃
下午如果您需要了解有关我的问题的更多信息才能回答我的问题,请问我。
最佳答案
单击AndroidManifest.xml,在文件页面底部看到``文本''和``合并的清单'',然后单击``合并的清单''->搜索``android.support.v4.content.FileProvider'',然后使用“androidx.core.content.FileProvider”
就是这样,确切的解决方案。
还要使用androidx版本库更改android.support.v4。请搜索新的androidx版本的android libraris