Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google ML kit Barcode Scanner example app for android not able to detect barcodes

I'm trying to use the Google ML kit barcode detection feature. For this, I have installed this example app provided by google. I have also connected my app to one of my firebase projects. When I open the app and go to LivePreviewActivity in that Barcode detection. The camera starts but no barcode is detected!. As per the quick start guide I've also added

<meta-data
    android:name="com.google.firebase.ml.vision.DEPENDENCIES"
    android:value="barcode" />

in my manifest file. Also I have included this

FirebaseVisionBarcodeDetectorOptions options =
            new FirebaseVisionBarcodeDetectorOptions.Builder()
                    .setBarcodeFormats(
                            FirebaseVisionBarcode.FORMAT_CODE_128)
                    .build(); 

in BarcodeScanningProcessor.java file.

The errors I'm getting is:

Barcode detection failed com.google.firebase.ml.common.FirebaseMLException: Waiting for the barcode detection model to be downloaded. Please wait.

E/BarcodeNativeHandle: Error Loading module

java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.chimera.DynamiteModuleInitializer"

I've installed this app on two phones Huawei Mate 8 and Samsung Galaxy S7 Edge. The app is not able to detect barcodes from both the phones.

My aim is to detect/scan barcodes from live camera preview. Thanks.

like image 855
CuriousHash Avatar asked May 15 '18 05:05

CuriousHash


People also ask

Can barcodes with ML kit on Android?

You can use ML Kit to recognize and decode barcodes. There are two ways to integrate barcode scanning: by bundling the model as part of your app, or by using an unbundled model that depends on Google Play Services. If you select the unbundled model, your app will be smaller.

Why is my barcode scanner not working on my phone?

If your Android device is not scanning a QR code, make sure the code is properly framed on your screen. Cleaning your camera lens and getting better lighting on the code are other potential solutions. You can also try using Google Lens or a third-party QR code app.


1 Answers

On the first part of the question "Waiting for the barcode detection model to be downloaded. Please wait.":

This can happen if there is not enough storage on the device or the data connection is not there on the device. Clear out the data of the Google Play Services and retrying should work:

Settings->Apps->Google Play Services->Storage->Manage Space->Clear All Data

On the meta-data tag in the manifest part of the question:

That helps with the production use case i.e. when the end-user installs the app from the Play Store, the models are downloaded at install time with that meta-data tag. However, during the development you still have to wait for the model to be downloaded once.

On the last part of the question about Dynamite module loading error (I don't have enough reputation to add a comment yet, so adding it here):

What Android version and the Google Play services version are you running?

like image 60
Pannag Sanketi Avatar answered Oct 20 '22 00:10

Pannag Sanketi