【发布时间】:2019-07-21 18:18:46
【问题描述】:
我已经在这个问题上讨论了大约 3 天,并且我已经尝试了我力所能及的一切。
React Native 给了我错误
react-native-image-picker : NativeModule.ImagePickermanger is Null. To fix this issue, try these steps;
Run react-native link react-native-image-picker in the project root.
Rebuild and re-run the App.
当我运行 react-native link react-native-image-picker 时,我得到 ;
info iOS module "react-native-image-picker" is already linked
info Android module "react-native-image-picker" is already linked
当我用 react-native 重建时
react-native run-android
然后用
重新运行npm start ( as shown on the screen),
回到原来的错误。这就像一个循环。
我在 Ubuntu 16.04 上使用 Android 模拟器 Nexus 7
代码段
import { ImagePicker } from 'react-native-image-picker';
_pickImage = () => {
const options = {
noData: true,
allowsEditing: true,
mediaTypes: "mixed",
quality: 0.5,
};
ImagePicker.launchImageLibrary(options, response => {
if (response.uri) {
let fileObj = {
key: this.state.attachments.length, //first image will have 0 here
fileInfo: response
};
this.state.attachments.push(fileObj);
this.setState((prevState) => ({
numFiles: parseInt(prevState.numFiles) + 1,
}))
}
});
};
_pickLiveImage = () => {
const options = {
noData: true,
allowsEditing: true,
mediaTypes: "mixed",
quality: 0.5,
};
ImagePicker.launchCamera(options, response => {
if (response.uri) {
let fileObj = {
key: this.state.attachments.length, //first image will have 0 here
fileInfo: response
};
this.state.attachments.push(fileObj);
this.setState((prevState) => ({
numFiles: parseInt(prevState.numFiles) + 1,
}))
}
});
};
我们将非常欢迎有关此问题的任何帮助或建议。
【问题讨论】:
-
你在哪里使用
react-native-image-picker? -
我在我的一个文件中使用它来进行图像上传,并为用户提供从屏幕拍照并直接上传的选项
-
请告诉我正在使用它的代码。
-
我已经更新了问题并添加了我的代码
-
你能改变这个吗?
import ImagePicker from 'react-native-image-picker';
标签: android react-native react-native-android react-native-image-picker