世博会启动Camera Async Android无法正常工作

时间:2019-09-18 10:00:44

标签: react-native expo

以下代码适用于expo,但在构建时不起作用。请帮助我。

_pickImage2 = async () => {
      await Permissions.askAsync(Permissions.CAMERA);
      await Permissions.askAsync(Permissions.CAMERA_ROLL);
      let result = await ImagePicker.launchCameraAsync({
        aspect: [4, 3],
        quality: 1
      });

      if (!result.cancelled) {
        var cr = this.state.count;
        this.setState({ ["image"+cr]: result.uri });
        var cn = this.state.count + 1;
        this.setState({ count:cn });
      }
};

1 个答案:

答案 0 :(得分:0)

向app.json添加权限并重建apk

 "android": {
      "package": "com.company.someapp",

      "permissions": [

        "CAMERA",
         "WRITE_EXTERNAL_STORAGE",
        "READ_EXTERNAL_STORAGE"
      ]
    }