I am trying to develop a PhoneGap application that uses the camera function. I follow the plugin documentation at https://build.phonegap.com/plugins/768 but no luck. Every time I try to use this function, I get the error “ReferenceError: Camera is not defined” when creating and testing on my Android device.
This is what the head of my index.html looks like:
<script type="text/javascript" src="phonegap.js"></script> <script type="text/javascript" src="cordova.js"></script>
And here is the script that I use to use the camera function:
<script> function take_picture(){ try{ navigator.camera.getPicture(cameraSuccess, cameraError, { quality: 50, destinationType: Camera.DestinationType.DATA_URL }); }catch(e){ alert(e); } } function cameraSuccess(imageData){ try{ $("#camera_image").attr('src', imageData); }catch(e){ alert(e); } } function cameraError(message){ try{ alert('Failed because: '+message); }catch(e){ alert(e); } } </script>
And since I use PhoneGap Build , here are the config.xml files that I use:
<gap:config-file platform="android" parent="/manifest"> <uses-permission name="android.permission.CAMERA" /> </gap:config-file> <feature name="http://api.phonegap.com/1.0/camera"/> <feature name="Camera"> <param name="android-package" value="org.apache.cordova.CameraLauncher" /> <param name="ios-package" value="CDVCamera" /> </feature>
source share