5

I tried Google barcode-reader from https://github.com/googlesamples/android-vision

This example doesn't work. When I tab to screen it always detect

"no barcode detected"

Debug reason :

private boolean onTap(float rawX, float rawY) {

    //TODO: use the tap position to select the barcode.
    BarcodeGraphic graphic = mGraphicOverlay.getFirstGraphic();
    Barcode barcode = null;
    if (graphic != null) {
        barcode = graphic.getBarcode();
        if (barcode != null) {
            Intent data = new Intent();
            data.putExtra(BarcodeObject, barcode);
            setResult(CommonStatusCodes.SUCCESS, data);
            finish();
        }
        else {
            Log.d(TAG, "barcode data is null");
        }
    }
    else {
        Log.d(TAG,"no barcode detected");
    }
    return barcode != null;
}

graphic variable is always Null

See the image:

Image on android studio

Anyone faced this problem? Can you let me know how to resolve it? Thank you so much!

Peter
  • 5,556
  • 3
  • 23
  • 38
MiduSparty
  • 51
  • 3

3 Answers3

2

So I guest you are new to Android Mobile Vision, in the new version of Google Play services (v9) they temporarily disabled the feature due to a serious bug in that feature, you can check the release note here:

https://developers.google.com/android/guides/releases#may_2016_-_v90

Vietnt134
  • 512
  • 7
  • 19
2

As @Vietnt134 have already answered, Android Mobile Vision is temporarily disabled.

You can follow this topic to know if something knew came up: https://github.com/googlesamples/android-vision/issues/98

People are pretty mad with Google about this. I hope they solve this quickly.

Nom4d3
  • 51
  • 4
1

getFirstGraphic returns null whenever no graphics have been added to the overlay; in the barcode example, this is when no barcodes have been detected in the frame.

Check if barcodeDetector.isOperational() is returning false in BarcodeCaptureActivity.java. If it's returning false, has for several minutes, and you aren't in a low storage condition, there's a very good chance this is because of a current service outage.

More details can be found here: https://github.com/googlesamples/android-vision/issues/98 We'll update that issue as soon as we have a resolution.