expo-camera: "^8.0.0"
sdkVersion: "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?
The method or property expo-camera.getAvailableCameraTypesAsync is not available on android, are you sure you've linked all the native dependencies properly?
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
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:
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
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.
In code run in react-native
context (as opposed to browser context) just check permissions and you should be good to go!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.