I am trying to get the Camera API to work in my PhoneGap android app, but i keep getting this error
"Cannot read property 'getPicture' of undefined".
Now i have checked countless answers on StackOverflow and tutorials all over the web,and tried all the answer there(with no luck), and i cant seem to find the issue.
This is the button that calls the function
<button type="button" class="btn btn-primary" ng-click="getPic()">Camera</button>
This is the controller that handles the camera
myApp.controller('EditProfileCtrl', function ($scope, $http, navigateFactory) {
$scope.getPic = function () {
navigator.camera.getPicture(onSuccess, onFail, {
quality: 60,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: 1
});
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed beause' + message);
}
};
});
Please comment if there is any additional information required. Any and all help will be hugely appreciated.
EDIT: So after following Aravin's advice i added <script src="cordova.js"></script>
now it atleast looks like something is happening, but now im getting these errors in my eclipse logcat:
I/System.out(3871): Error adding plugin org.apache.cordova.CameraLauncher D/PluginManager(3871): exec() call to unknown plugin: Camera
So after trying all the things here with no success I did this which fixed the issue (dont know how)...
remove the plugin , build , add the plugin , build
and Magic!