react-native-image-picker 安装破坏了我的应用程序 [英] react-native-image-picker installation breaks my app

查看:54
本文介绍了react-native-image-picker 安装破坏了我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一步:npm install react-native-image-picker
......应用程序仍在构建中......
第 2 步:react-native 链接 react-native-image picker
...应用不再编译

Step 1: npm install react-native-image-picker
......app is still building fine.....
Step 2: react-native link react-native-image picker
...app no longer compiles

当我清理 gradle 时出现错误:无法将进程工作目录设置为'C:\code\rn\xs\node_modules\react-native-image-picker\example\android':无法设置当前目录(错误号 3)"

When I clean gradle I get error: "Could not set process working directory to 'C:\code\rn\xs\node_modules\react-native-image-picker\example\android': could not set current directory (errno 3)"

当我尝试在 gradle 中重建时,我也收到错误消息:清单合并失败:属性 application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91也存在于 [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).建议:在 AndroidManifest.xml:6:5-117 的元素中添加 'tools:replace="android:appComponentFactory"' 以覆盖".

When I try to rebuild in gradle I also get error: "Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:6:5-117 to override".

所以我接受错误消息的建议并将tools:replace="android:appComponentFactory""添加到应用程序元素.....
我现在清洁时仍然遇到相同的错误.....但是重建时的错误有点不同:tools:replace 在第 10 行为属性 android:appComponentFactory 指定,但未指定新值."
.

请帮忙!!

So I take suggestion of error message and add 'tools:replace="android:appComponentFactory"' to application element.....
I now still get same error when I clean.....but error when I rebuild is a little different: "tools:replace specified at line:10 for attribute android:appComponentFactory, but no new value specified."
.

Please help!!

推荐答案

作为 Lenoarod 答案的补充,您可以使用 喷射器库.它将帮助您转换所有尚未转换为 AndroidX 的库.

As addition for Lenoarod answer, you can use jetifier library. It will help you to convert all library that hasn't converted to AndroidX.

根据它的文档

所以现在您需要将您的应用程序转换为 AndroidX,但是您的许多 react-native 库都提供了本机 Java 代码并且尚未更新.这是怎么做的?

So now you need to convert your app to AndroidX, but many of your react-native libraries ship native Java code and have not updated. How is this done?

首先,使用 Android Studio 的重构工具将您的应用转换为:Android 开发者文档
1. npm install --save-dev jetifier
2. npx jetify
3. npx react-native run-android (你的应用应该可以正确编译和工作)
4. 在 package.json 的 postinstall 目标中调用 npx jetify run(任何时候你的依赖项更新你都必须再次 jetify)

First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
1. npm install --save-dev jetifier
2. npx jetify
3. npx react-native run-android (your app should correctly compile and work)
4. Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)

这篇关于react-native-image-picker 安装破坏了我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆