[英]errors: expo-camera.isAvailableAsync and expo-camera.getAvailableCameraTypesAsync is not available on android
expo-camera: "^8.0.0"世博相机:“^8.0.0”
sdkVersion: "36.0.0" SDK版本:“36.0.0”
Hello people, when i try:大家好,当我尝试:
import { Camera } from 'expo-camera';
...
const cameraIsAvailable = await Camera.isAvailableAsync()
const availablesCameraTypes = await Camera.getAvailableCameraTypesAsync()
console.log("cameraIsAvailable: ", cameraIsAvailable)
console.log("availablesCameraTypes: ", availablesCameraTypes)
i get the fallowing errors:我得到了以下错误:
expo-camera.isAvailableAsync is not available on android, are you sure you've linked all the native dependencies properly? expo-camera.isAvailableAsync 在 android 上不可用,您确定您已正确链接所有本机依赖项吗?
The method or property expo-camera.getAvailableCameraTypesAsync is not available on android, are you sure you've linked all the native dependencies properly?方法或属性 expo-camera.getAvailableCameraTypesAsync 在 android 上不可用,您确定您已正确链接所有本机依赖项吗?
the problem just disappear when i remove:当我删除时,问题就消失了:
state = {
...
cameraType: Camera.Constants.Type.front,
};
...
<Camera
type={this.state.cameraType}
flashMode={flashMode}
style={styles.preview}
ref={camera => this.camera = camera}
/>
and change it by:并通过以下方式更改它:
state = {
...
cameraType: Camera.Constants.Type.back,
};
and i change "cameraType" by我改变了“cameraType”
componentDidMount = () => {
this.props.navigation.addListener('didFocus', async () => {
await setTimeout(() => {
this.setState({ cameraType: Camera.Constants.Type.front })
}, 100)
});
}
it seems its an error from expo-camera... so when i try to call these methods:这似乎是 expo-camera 的一个错误......所以当我尝试调用这些方法时:
const cameraIsAvailable = await Camera.isAvailableAsync()
const availablesCameraTypes = await Camera.getAvailableCameraTypesAsync()
i get following errors: errors: expo-camera.isAvailableAsync and expo-camera.getAvailableCameraTypesAsync is not available on android我收到以下错误: 错误:expo-camera.isAvailableAsync 和 expo-camera.getAvailableCameraTypesAsync 在 android 上不可用
The methods you're trying to use, Camera.isAvailableAsync
and Camera.getAvailableCameraTypesAsync
are marked in the documentation as Web only , so calling them will only work, well, on Web.您尝试使用的方法
Camera.isAvailableAsync
和Camera.getAvailableCameraTypesAsync
在文档中标记为Web only ,因此调用它们只能在 Web 上工作。
In code run in react-native
context (as opposed to browser context) just check permissions and you should be good to go!在
react-native
上下文(而不是浏览器上下文)中运行的代码中,只需检查权限即可!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.