[英]Cordova Camera access crash app on Nexus 7 with Android 6.0.1
Using Cordova 6.3.1, I installed the following Crodova plugins: cordova-plugin-camera, cordova.plugins.diagnostic, phonegap-plugin-barcodescanner 使用Cordova 6.3.1,我安装了以下Crodova插件:cordova-plugin-camera,cordova.plugins.diagnostic,phonegap-plugin-barcodescanner
I'm using the following JavaScript code to access the Camera and scan a QR code: 我正在使用以下JavaScript代码访问相机并扫描QR码:
function scanQR() {
cordova.plugins.diagnostic.requestCameraAuthorization(function(status) {
console.log("Authorization request for camera returned " + status);
if (status == cordova.plugins.diagnostic.permissionStatus.GRANTED) {
try {
cordova.plugins.barcodeScanner.scan(scanQRDone, function (error) {
console.log(error);
});
} catch (e) {
console.log(e.message);
}
}
}, function (error) {
console.log(error);
});
}
function scanQRDone(result) {
console.log(result);
}
The requestCameraAuthorization call prompts for a confirmation on the device and when allowed returns status GRANTED. requestCameraAuthorization调用提示在设备上进行确认,并在允许时返回已授予状态。 However the call to cordova.plugins.barcodeScanner.scan simply crashes the application on the Nexus 7.
但是,对cordova.plugins.barcodeScanner.scan的调用只会使Nexus 7上的应用程序崩溃。
The actual line in which the crash occurs is cordova.js line 940: 发生崩溃的实际行是cordova.js行940:
var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
Where service="BarcodeScanner" and action="scan" Seems like some kind of version mismatch in native code, any ideas are welcomed. 其中service =“ BarcodeScanner”和action =“ scan”好像本机代码中的某种版本不匹配,欢迎任何想法。
从头开始创建新的离子应用程序并将www文件夹的内容复制到其中,已解决了该问题。
in the file config.xml add this 在文件config.xml中添加此
< platform name="android" > <br>
< preference name="android-targetSdkVersion" value="23" /> <br>
< /platform>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.