2017-02-14 201 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/