0

我已经在这个问题上讨论了大约 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,
        }))
      }
    });
  };

对此问题的任何帮助或建议都将受到高度欢迎。

4

1 回答 1

0

我试过了,它绝对完美。当你

RN >= 0.60

cd ios && pod 安装

RN < 0.60

react-native 链接 react-native-image-picker

于 2019-09-30T11:48:10.043 回答