google-mlkit codescanner not works after 1 week

113 views Asked by At

I have made an app in which I have included the Google scanner(CodeScanner) with autozoom and everything necessary to be able to implement the reading of datamatrix codes. On Android Gradle I use the following line:

implementation 'com.google.android.gms:play-services-code-scanner:16.1.0'

The code of my button is the following and I send the value of the scanned datamatrix to a textview:

public void onScanButtonClicked(View view) {
    GmsBarcodeScannerOptions.Builder optionsBuilder = new GmsBarcodeScannerOptions.Builder();
    if (allowManualInput) {
      optionsBuilder.allowManualInput();
    }
    if (enableAutoZoom) {
      optionsBuilder.enableAutoZoom();
    }
    GmsBarcodeScanner gmsBarcodeScanner =
        GmsBarcodeScanning.getClient(this, optionsBuilder.build());
    gmsBarcodeScanner
        .startScan()
        .addOnSuccessListener(barcode -> barcodeResultView.setText(getSuccessfulMessage(barcode)))
        .addOnFailureListener(
            e -> barcodeResultView.setText(getErrorMessage(e)))
        .addOnCanceledListener(
            () -> barcodeResultView.setText(getString(R.string.error_scanner_cancelled)));
  }

Everything works fine but after a week of testing the Google scanner has been deactivated and it no longer works on the phones that had the application installed. The error it gives me is the following:

com.google.mlkit.common.mlkitexception failed to scan code

However, if I install the application on another new phone it works.

What could be the problem?

0

There are 0 answers