[英]React-Native-Crop-Image doesn't work on android , How to crop images on android and it should be same for ios also
I have tried this library react-native-image-crop-picker as suggested on this stackoverflow answer我已经按照这个 stackoverflow 答案的建议尝试了这个库react-native-image-crop-picker
I have followed each and every step mentioned here我已经按照这里提到的每一步
npm i react-native-image-crop-picker@0.4.2
npm i react-native-image-crop-picker@0.4.2
import ImagePicker from 'react-native-image-crop-picker';
thenImagePicker.openPicker({ width: 300, height: 400, cropping: true }).then(image => { console.log(image); });
ImagePicker.openPicker({ width: 300, height: 400, cropping: true }).then(image => { console.log(image); });
Also in // file: android/settings.gradle
have added the below code同样在
// file: android/settings.gradle
添加了以下代码
include ':react-native-image-crop-picker' project(':react-native-image-crop-picker').projectDir = new File(settingsDir, '../node_modules/react-native-image-crop-picker/android')
include ':react-native-image-crop-picker' project(':react-native-image-crop-picker').projectDir = new File(settingsDir, '../node_modules/react-native-image-crop-选择器/安卓')
Also as mentioned in the documentation have added required code in build.gradle
& MainActivity.java
file另外如文档中所述,已在
build.gradle
和MainActivity.java
文件中添加了所需的代码
But this is not working for me on Android
but working perfectly on iOS
.但这在
Android
iOS
工作得很好。 On Android
I have given to crop images by scale type only not as flexible crop.在
Android
,我只按比例类型裁剪图像,而不是灵活裁剪。
I think you have faced the problem for version issue.我认为您遇到了版本问题。 You should try react-native-amazing-cropper .
你应该试试react-native-amazing-cropper 。 It works same for both the
Android
and iOS
.它对
Android
和iOS
的工作原理相同。
I had the same problem.我有同样的问题。 I found out that we need the following line in our AndroidManifest.xml file.
我发现我们的 AndroidManifest.xml 文件中需要以下行。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" ... >
...
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />
Enjoy.享受。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.