2017-02-14 203 views
0

我有一个离子项目,我安装了这个插件扫描qrcodes:错误扫描条形码与离子/科尔多瓦

cordova plugin add https://github.com/wildabeast/BarcodeScanner.git 

但是,当我一个三星S5采用Android 6.0的设备上运行的应用程序,我得到一个相机错误: “很抱歉,Android相机出现了问题,您可能需要重启设备。” enter image description here

任何的是什么原因导致这个问题的想法?

我与测试:

ionic run android -l -c 
ionic run android 

这是当我按下一个按钮,执行我的代码:

$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); 
    }); 
    }); 
}; 
+0

嗨..我有同样的问题,Experia还Z5 ......在其他设备它的工作...我的建议是尝试设置的最低SDK版本andoird ..不是试图在config.xml添加:

+0

Did解决你的问题?然而,我正在使用另一个插件“https://github.com/wildabeast/BarcodeScanner.git” –

+0

详细的博客:http://sforsuresh.in/cordova-sorry-android-camera-encountered-problem/ –

回答

1

这是解决我的problema,在config.xml文件中的“ android“平台部分我把:

<platform name="android"> 
    <preference name="android-targetSdkVersion" value="22"/> 
</platform> 
2

对于这个问题,你可以尝试以下任一解决方案:
1)它是Android 6的权限问题。所以将问题配置平台修复为android 5.0。

,或者如果您使用MI注4,你可以试试下面的额外步骤:

有一个在MIUI系统secruity需要其他的许可,并在启用后,相机开始工作。
以下是您可以按照以更新设置的步骤:
1)转到安全性。
2)点击“权限”,再次选择“权限”
3)现在从列表中,点击“相机”。
4)它会列出所有安装的应用程序。查找您的应用并启用权限。

R效率:http://sforsuresh.in/cordova-sorry-android-camera-encountered-problem/