我正在完成一个应用程序。调试APK工作正常,而在商店上发布的签名版本不能正常工作,使我无法检查错误。
这个问题与我添加到项目中的条形码扫描器有关
$ ionic cordova plugin add phonegap-plugin-barcodescanner
$ npm install @ionic-native/barcode-scanner我不明白为什么这两个apks的行为不同。
我想这可能是权限问题,但我没有找到足够的文档
发布于 2019-06-18 17:08:35
我用这个“解决”了这个问题:
// import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
// private barcodeScanner: BarcodeScanner,
barcodeScanner = (<any>window).cordova.plugins.barcodeScanner;发布于 2019-08-04 21:29:20
权限
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.CAMERA" />我通过在/platform/app/src/main/AndroidManifest.xml添加此权限来解决此问题
重新编译你的应用程序,然后它会询问用户访问摄像头的权限。
好了。
发布于 2019-06-17 16:10:36
奇怪!我最近一直在使用同样的条形码扫描器,在调试模式下,它工作得很好。
当我更改包名称时,它会将所有内容重置为默认设置,因此系统会再次要求我提供权限。
这一次作为实验,我否认了这一点。
应用给出了一个错误“错误:非法访问”。
你有没有什么东西来解决这类问题呢?
这就是我所拥有的:
async scanCode() {
try {
let barcodeData: BarcodeScanResult = await this.barcodeScanner.scan(this.barcodeScannerOptions);
if (barcodeData.cancelled) {
await this.msg.showAutoDismissToast("QR code scan cancelled");
this.analytics.trackEvent("QR code scan cancelled");
return;
}
this.addScannedDataToList(barcodeData);
const scanResultModal = await this.modalController.create({
component: ScanResultModalPage
});
await scanResultModal.present();
await this.msg.showAutoDismissToast("QR code scanned");
} catch (err) {
await this.msg.showAutoDismissToast("Error: " + err);
}
}您需要根据您的情况对其进行一些调整,但它显示了try catch的基本思想。
我的showAutoDismissToast不是什么花哨的东西,只是一个标准的代码片段:
async showAutoDismissToast(message) {
let toast = await this.toastController.create({
message,
duration: 2000,
position: 'bottom'
});
await toast.present();
}希望把这样的东西放进去会暴露出阻止你的扫描仪工作的错误。
https://stackoverflow.com/questions/56601999
复制相似问题