Reputation: 828
I have an Ionic project and I installed this plugin to scan qrcodes:
cordova plugin add https://github.com/wildabeast/BarcodeScanner.git
But when I run the app on a samsung s5 device with Android 6.0 I get a camera error:
"Sorry, the Android camera encountered a problem. You may need to restart the device"
Any ideas of what causes this issue?
I have tested with:
ionic run android -l -c
ionic run android
This is my code executed when I press a button:
$scope.scanBarcode = function() {
$ionicPlatform.ready(function() {
$cordovaBarcodeScanner.scan().then(function(imageData) {
console.log("Barcode text -> " + imageData.text);
console.log("Barcode Format -> " + imageData.format);
console.log("Cancelled -> " + imageData.cancelled); // prints: cancelled
}, function(error) {
console.log("An error happened -> " + error);
});
});
};
Upvotes: 0
Views: 982
Reputation: 16086
For this issue you can try either of below solutions:
OR if you are using MI note 4 you can try below additional steps:
There is another permission required in MIUI secruity system and after enabling it, camera started working.
Following are the steps you can follow to update the setting:
Upvotes: 2
Reputation: 828
This is what solved my problema, in the config.xml file in the "android" platform section I put:
<platform name="android">
<preference name="android-targetSdkVersion" value="22"/>
</platform>
Upvotes: 1