4

I am trying to use Barcode API following this sample https://github.com/googlesamples/android-vision/tree/master/visionSamples/barcode-reader but can't get the BarcodeDetector to work.

BarcodeDetector is not operational. The log is full of these two messages:

11-18 17:01:17.346 6661-6800/me.androidwrapper I/Vision: Loading library libbarhopper.so
11-18 17:01:17.347 6661-6800/me.androidwrapper I/Vision: libbarhopper.so library load status: false

I assume that the library couldn't be downloaded. I have 4 GB free in memory.

gradle.build

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.0"

        defaultConfig {
            applicationId "me.androidwrapper"
            minSdkVersion 22
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')

        compile 'com.android.support:appcompat-v7:22.0.0'
        compile 'com.google.code.gson:gson:2.3.1'
        compile 'commons-codec:commons-codec:1.10'

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

AndroidManifest.xml

  <?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="me.androidwrapper"
    android:installLocation="auto">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.NFC" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_fy_logo"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="barcode" />


        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main"
            android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SettingsActivity"
            android:label="@string/title_activity_settings" />
        <activity android:name=".BarcodeCaptureActivity"
            android:label="Read Barcode"/>
    </application>

</manifest>

I also tried to restart the phone and uninstall the application manually.

Device: Honor 7 with android 7

Thanks for help

jakub.petr
  • 2,951
  • 2
  • 23
  • 34
  • I am still facing the same issue on the emulator. Clearing play service data didn't work for me. do you have any alternative? – Rohan J Mohite Jul 19 '18 at 08:59

2 Answers2

5

I encountered the same issue. In my case, it was because of low space/memory issue. I tried to free up some space/memory, but this issue still persisted even after restart and reinstall.

I did "Clear data" for "Google Play services for Instant Apps" and somehow this issue get resolved.

Dj_k_
  • 51
  • 1
  • 5
  • I had enough free space, but clearing the data if Google Play Services did indeed work. The library was then downloaded, and I could scan a Barcode. – yennsarah Jun 05 '18 at 06:04
  • Ok so this worked for me too. Go to Settings > Apps > Google Play Services > Storage > Clear cache and data. Opened app again and library downloaded directly – GabLeRoux Aug 08 '19 at 02:07
0

Tried a bunch of different things found on web, and these are the steps that fixed it for me:

  • Deleted my app
  • Updated google play services to the latest version
  • Cleared the cache and all data from Google Play Services
  • Re-installed my app
Alberto M
  • 1,608
  • 1
  • 18
  • 42
  • Wouldn't Build >> Clean Project, then Build >> Rebuild Project achieve the same effect? (I'm on Android Studio 2022) – LabGecko Jul 25 '23 at 10:30
  • 1
    it wasn't a matter of building the project, but more of the services installed on the physical device. Unfortunately I don't remember a lot, since 3 years have gone by. – Alberto M Jul 25 '23 at 13:18