Cannot read property 'Aspect' of undefined #272
Comments
Initial debugging shows that CameraModule is undefined after line 12 in Camera.js const CameraManager = NativeModules.CameraManager || NativeModules.CameraModule; -> console.log(CameraManager) here shows that CameraManager is undefined |
Hi, I get the same error, why is this issue closed? Is it already fixed? |
If you are using: Try |
I used import and i got this error |
@mkhanal I ran into this issue as well. For me it was because it was not properly installed in my xcodeproject. I ran through the install instructions again and it worked :) |
Thank you @tkjone, followed the manual installation instructions (no rnpm) and it worked! |
@tkjone...unfortunately i am not using xcodeproject. I just use the command line and that's where i hit the issue. I've run through the instructions multiple times and even cleaned and reinstalled the whole environment. :( |
@VansonLeung switching from var ... = require to the import worked for me, thank you! |
BTW...for me its failing for android development |
After linked the library into your android project, you need to reinstall the project on your phone/emulator with |
@martinezguillaume that solves the issue, thanks |
I was experiencing the same error only in android - the best way to deal with this is to make sure the project is not running when doing the initial install - for ex: stop the android emulator and the android packager running in the terminal. I was also getting this error and it's related to the installation: |
In addition to the above the documentation is also inaccurate for react native 0.29.0 - don't make changes to MainActivity.java. Instead make changes to MainApplication.java:
|
Need help, I got the same issue on iOS. |
Android is worked but get error on IOS, I have tried auto linked and manual linked the package |
import React, {Component} from 'react';
import {
AppRegistry,
View,
StyleSheet,
Dimensions,
TouchableHighlight,
Image,
Text,
} from 'react-native';
import Camera from 'react-native-camera';
...
class CameraRoute extends Component {
constructor(props) {
super(props);
this.state = {
path: null,
};
}
takePicture() {
this.camera.capture()
.then((data) => {
console.log(data);
this.setState({path: data.path})
})
.catch(err => console.error(err));
}
renderCamera() {
return (
<Camera
ref={(cam) => {
this.camera = cam;
}}
style={styles.preview}
aspect={Camera.constants.Aspect.fill}
captureTarget={Camera.constants.CaptureTarget.disk}
>
<TouchableHighlight
style={styles.capture}
onPress={this.takePicture.bind(this)}
underlayColor="rgba(255, 255, 255, 0.5)"
>
<View />
</TouchableHighlight>
</Camera>
);
}
renderImage() {
return (
<View>
<Image
source={{uri: this.state.path}}
style={styles.preview}
/>
<Text
style={styles.cancel}
onPress={() => this.setState({path: null})}
>Cancel
</Text>
</View>
);
}
render() {
return (
<View style={styles.container}>
{this.state.path ? this.renderImage() : this.renderCamera()}
</View>
);
}
};
export default CameraRoute; CameraManager.Aspect is undefined. This error occurred on Android. |
I had the same problem with iOS version. JPN is right. |
I'm having the same issue when trying to jest snapshot a component using it:
result:
|
@hybrisCole did you have any luck with solving that issue? |
@thomasobrien99 sorry man, I made a post w my use case here so the guys are aware but haven't tried anything else to solve it |
@hybrisCole Same here! any luck? |
IOS: |
+1 |
Update: |
I have the same issue, tried auto and manual install. |
The camera run smoothly on iOS and Android emulator. Result:
|
u can create a mock for react-native-camera something like this:
// react-native-camera.js const Camera = {}
export default Camera; |
I got this error on iOS and rebuilding on device fixed the issue. |
same issue. I use atom as my environment. I have cleaned and reinstalled node_modules and re-run the project. Checked I have linked elements and put the ios10 warnings in info.plist. I use the import keyword. EDIT : sorry this was my own fault - using react-native <0.4 and had installed react-native-camera0.5 {leaving in case this helps anyone} |
i got the same error on iOS, need help ! undefined is not an object(evaluating 'CameraManager.Aspect') |
Me too :/ |
Like @Ajackster mentioned, for iOS, removing the app from my device and then rebuilding via XCode worked for me. |
can somebody help me to resolve this issue. i am getting this error when i run |
@AshokICreate did you see sibelius's comment for using mocks? |
I get this error when using react-native-camera with the react-native-navigation package. I have tried building on an Android device (as well as emulator), reinstalling package, deleting node_modules and npm install, update. I have had this camera package working many times but each time I try to get it working with some navigator something breaks. With the original navigator package, it works but each time I go back to the camera the app crashes. |
same issue and I'm also using react-native-navigator too :/ +1 |
Same issue on ios. |
I am getting the issue on android. Have performed the manual installation steps as well. |
Seems like a required step. Should be in Getting Started docs? |
yes, @kjkta pretty much every native module will need this step, fyi! |
Seeing this issue as well (also using |
I had this issue in the simulator. Removing the app from the simulator and running |
|
+1 |
|
rebuilds |
I was seeing a similar problem when running jest tests, and mocking
|
I also have this issue. Then I find that I missed two steps in the documentation. First remember to add permissions in plist file.
Then remember to add dependency in your podfile.
For me it works after these two steps. If it still not work, check if you link the library properly. Hope it helps. |
react-native link react-native-camera,then,react-native run-ios |
this work for me in iOS
done. |
If someone is still facing this issue, then please remember to follow the steps to ensure Face Detection is removed from the project. |
In iOS:
Works fine for me! |
@devtas Im actually attempting this now, and I cannot get a build through. yet the ...If I search for it in the Did you do anything differently? |
Steps to reproduce
Expected behaviour
Should instantiate camera
Actual behaviour
Cannot read property 'Aspect' of undefined
Environment
react-native-camera
Version: "master"
The text was updated successfully, but these errors were encountered: