EddyVerbruggen / nativescript-barcodescanner

🔎 NativeScript QR / barcode (bulk)scanner plugin
MIT License
293 stars 73 forks source link

Configuration error #262

Open tostamista23 opened 3 years ago

tostamista23 commented 3 years ago

Hi, when i try to open the scanner i get "Configuration error"

Phone: Xiaomi 9S Android: 11

Both available() and hasCameraPermission() return true

Permissions:

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

tns platform remove android then tns platform add android didnt help

Package.json

"@angular/animations": "~11.0.0",
"@angular/common": "~11.0.0",
"@angular/compiler": "~11.0.0",
"@angular/core": "~11.0.0",
"@angular/forms": "~11.0.0",
"@angular/platform-browser": "~11.0.0",
"@angular/platform-browser-dynamic": "~11.0.0",
"@angular/router": "~11.0.0",
"@aspnet/signalr": "^1.0.27",
"@nativescript/angular": "~11.0.0",
"@nativescript/core": "~7.1.3",
"@nativescript/theme": "~3.0.0",
"@nstudio/nativescript-checkbox": "^2.0.4",
"@triniwiz/nativescript-toasty": "^4.1.1",
"core-js": "^3.8.0",
"nativescript-barcodescanner": "^4.1.0",
"nativescript-theme-core": "^2.0.24",
"nativescript-ui-listview": "^9.1.0",
"nativescript-ui-sidedrawer": "^9.0.3",
"nativescript-websockets": "^1.5.6",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.6.0",
"tslib": "~2.0.0",
"zone.js": "~0.11.1"
doScanWithBackCamera() {
    this.scan(false, true);
}

private scan(front: boolean, flip: boolean, torch?: boolean) {
    new BarcodeScanner().scan({
      formats: "QR_CODE,PDF_417",   // Pass in of you want to restrict scanning to certain types
      cancelLabel: "EXIT. Also, try the volume buttons!", // iOS only, default 'Close'
      cancelLabelBackgroundColor: "#333333", // iOS only, default '#000000' (black)
      message: "Use the volume buttons for extra light", 
      showFlipCameraButton: true,  
      preferFrontCamera: false,     
      showTorchButton: true,      
      beepOnScan: true,            
      fullScreen: true,  
      torchOn: false,
      closeCallback: function() { console.log("Scanner closed"); }, 
      resultDisplayDuration: 500, 
      orientation: "landscape",  
      openSettingsIfPermissionWasPreviouslyDenied: true previously denied
    }).then(
      function(result) {
        console.log("Scan format: " + result.format);
        console.log("Scan text:   " + result.text);
      },
      function(error) {
        console.log("No scan: " + error);
      }
    );
  }

HTML

<Button class="btn btn-primary btn-rounded-sm" text="OPEN" (tap)="doScanWithBackCamera()"></Button>

Thanks for any help

EDIT 1: Its seems intent.resolveActivity returns null even after removing and adding platform

ikiK-CRO commented 3 years ago

I have been at this for two strait days also. NS8 Core, all cheeks on permissions granted and what ever i try i get:

JS: Camera permission was already granted JS: No scan: Configuration error

Also, granted in manifest, also made tns clean even. Its funny tho that I event pulled demo app from git and that is working on my device. I have been over all possible articles and compering demo with my app I see no reasons not to work.

chimmelb commented 3 years ago

Same. Updated to NS8 today and started receiving this same error "Configuration Error". There is only one reference in the code. Some setup/gradle issues related to intent.resolveActivity(Utils.ad.getApplicationContext().getPackageManager()) !== null?

tostamista23 commented 3 years ago

Going back to nativescript-barcodescanner@4.0.1 fix the problem for me, maybe 4.1.0 only supports ns8+? After downgrading, if you are getting Cannot read property 'client' of undefined make sure to delete and add platform tns platform remove android then tns platform add android

ikiK-CRO commented 3 years ago

I could kiss you right now. Just downgrade to 4.0.1 fixed the issue.

Thanks, I was stuck at this for days.

EddyVerbruggen commented 3 years ago

Interesting, thanks for the report!

I think the 4.1 version was only tested on iOS (because that's the only platform the app I'm using this plugin for is targeting). I'll take a look soon.

LaKing commented 3 years ago

Bumped into this too ....

ikiK-CRO commented 3 years ago

Yeah I just got iPhone to test the app, it does not work on iPhone. But works on android when reverted back. Only way to use my app is thru registration by scanning the barcode from my desktop app. So this would be HUGE help if this bug could be fixed.

EddyVerbruggen commented 3 years ago

Seems like the publish-script fired back at me. I've just published 4.1.1 which should fix the issue for both iOS and Android. Thanks for your patience!

chimmelb commented 3 years ago

This worked for me. Thank you! npm install nativescript-barcodescanner@4.1.1 --save ns platform remove android ns run android