Google Vision barcode library not found

I’m trying to use the new feature in Google Play Services (Vision) to add QR code scanning to my application. But when I run my app I get this:

I/Vision﹕ Supported ABIS: [armeabi-v7a, armeabi]
D/Vision﹕ Library not found: /data/data/com.google.android.gms/files/com.google.android.gms.vision/barcode/libs/armeabi-v7a/libbarhopper.so
I/Vision﹕ Requesting barcode detector download.

I have declared barcode dependency as per tutorial:

  • Unable to resolve target 'android-21'
  • Different values folders in android
  • display NetworkImageView's default image without network request
  • animation-list not working in Android 5.0 (Lollipop)
  • How do I set ANDROID_SDK_HOME environment variable?
  • Date formatting based on user locale on android
  • <meta-data
        android:name="com.google.android.gms.vision.DEPENDENCIES"
        android:value="barcode" />
    

    I tried reinstalling the app and restarting the phone, nothing helps.

    Using Google Play Services 7.8, version installed on the device is 7.8.11.

    compile 'com.google.android.gms:play-services-vision:7.8.0'
    

    Code used for creating the barcode detector:

    boolean initBarcodeDetector() {
        final BarcodeTrackerFactory barcodeTrackerFactory = new BarcodeTrackerFactory(this);
        final MultiProcessor<Barcode> multiProcessor = new MultiProcessor.Builder<>(barcodeTrackerFactory)
                .build();
        barcodeDetector = new BarcodeDetector.Builder(this)
                .build();
        barcodeDetector.setProcessor(multiProcessor);
    
        if (barcodeDetector.isOperational() == false) {
            Toast.makeText(this, R.string.barcode_not_operational, Toast.LENGTH_LONG).show();
            finish();
            return false;
        }
    
        return true;
    }
    

    the above close returns false and finishes activity because barcodeDetector.isOperational() returns false.

    Related posts:

    Does Android support near real time push notification?
    Set different minSdkVersion for testAndroid than for main app
    Forcing adjustPan in activity containing ScrollView
    Google Maps Javascript API mobile performance issue
    Ormlite setup without using base activities
    ARC Welder cuts off the action bar
  • Play Youtube HTML5 embedded Video in Android WebView
  • How to record android screen with Android Studio?
  • How do I make Views fill the full width of their parent in my Android app?
  • View moves with soft keyboard, blocking other UI objects
  • GooglePlayServicesUtil.isGooglePlayServicesAvailable() crashes
  • How to avoid DEX 64K LIMIT by importing the right library
  • 6 Solutions collect form web for “Google Vision barcode library not found”

    Google has confirmed a bug that they will fix soon, which prevents you in some cases to use this library of barcode/face-detection (link here) :

    • A service required by Mobile Vision is now disabled due to a serious bug in that service. This will prevent users who have not
      already used face or barcode detection from using those features. We
      do not recommend adding new Mobile Vision features to your app until
      this issue is fixed.
    • For apps that already use Mobile Vision features, check FaceDetector.isOperational() or BarcodeDetector.isOperational() to
      confirm detector readiness before using the face or barcode detector.

    It’s also written in some issues reported on Google’s github sample repo:

    https://github.com/googlesamples/android-vision/issues

    Example (here) :

    There is a known issue with the new version of GMSCore (v9) that was
    just released today.

    It started working after I cleared cache and freed up some space. I had “only” 400mb free space and there was no error message which would indicate that.

    I also experienced this, the vision library could not be found on one of my test devices, although the console showed a request of the library on every start of the app, but never finished. I tested on Nexus 4,5 Motorola X2, Samsung S 2-6 and various other devices, the S5 was the only devices with the Problem. There was enough free space with over 2Gb, after hard resetting the device the scanning worked instantly as intended.

    Based on the documentation here: https://developers.google.com/android/reference/com/google/android/gms/vision/package-summary and here: https://developers.google.com/android/reference/com/google/android/gms/vision/Detector#isOperational()

    Documentation:

    public boolean isOperational()

    Indicates whether the detector has all of the required dependencies
    available locally in order to do detection.

    When an app is first installed, it may be necessary to download
    required files. If this returns false, those files are not yet
    available. Usually this download is taken care of at application
    install time, but this is not guaranteed. In some cases the download
    may have been delayed.

    If your code has added a processor, an indication of the detector
    operational state is also indicated with the detectorIsOperational()
    method. You can check this in your app as it processes detection
    results, and can convey this state to the user if appropriate.

    Returns •true if the detector is operational, false if the dependency
    download is in progress

    and

    public boolean detectorIsOperational()

    Returns true if the detector is operational, false if it is not
    operational. In the non-operational case, the detector will return no
    results.

    A detector may be non-operational for a while when starting an app for
    the first time, if a download is required to obtain the associated
    library and model files required to do detection.

    It looks like your device needs to finish downloading the libraries through Google Play Services in order for your application to work right away.

    Based on the Google Samples(a comment in the source):

            // Note: The first time that an app using the barcode or face API is installed on a
            // device, GMS will download a native libraries to the device in order to do detection.
            // Usually this completes before the app is run for the first time.  But if that
            // download has not yet completed, then the above call will not detect any barcodes
            // and/or faces.
            //
            // isOperational() can be used to check if the required native libraries are currently
            // available.  The detectors will automatically become operational once the library
            // downloads complete on device.
    

    https://github.com/googlesamples/android-vision/blob/master/visionSamples/multi-tracker/app/src/main/java/com/google/android/gms/samples/vision/face/multitracker/MultiTrackerActivity.java#L156

    I also had same experience.
    (sorry I can’t comment to add my case because I only have 1 rep)
    I am using Nexus 5 (2013) with marshmallow (6.0).
    I started with 1gb free space and didn’t work and didn’t work at 2gb.
    I ended up freeing another 1gb (so 3gb free space) then it worked.

    Mobile Vision operation is restored in Google Play Services v9.2
    https://developers.google.com/vision/release-notes#google_play_services_92

    Release Notes

    Here are the updates to the Mobile Vision API, corresponding to the
    Google Play Services releases.

    Google Play Services 9.2

    Bug Fixes

    Mobile Vision operation is restored in Google Play Services v9.2.
    Users with the new version will be able to download the required files
    and make use of application features powered by Mobile Vision. The
    Google Play Services update also includes a configuration update as
    part of the fix for Mobile Vision. Normally this is updated once every
    several days, but it will also occur on phone reboot (though this it
    is throttled, so this is not guaranteed to update the configuration).
    Since file download errors can still occur (e.g. if there is
    insufficient storage on the device), we advise Google Play Services
    developers to call FaceDetector.isOperational() or
    BarcodeDetector.isOperational() to check for detector readiness and
    degrade feature operation accordingly.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.