detector.isOperational() always false on android

淺唱寂寞╮ 提交于 2019-12-01 18:53:54

It looks like the first time barcode detector is used on each device, some download is done by Google Play Services. Here is the link:

https://developers.google.com/vision/multi-tracker-tutorial

And this is the excerpt:

The first time that an app using barcode and/or face APIs is installed on a device, GMS will download a libraries to the device in order to do barcode and face detection. Usually this is done by the installer before the app is run for the first time.

I had this problem now. You can't update the Google Play Services. After I used the same as on the tutorial it works.

compile 'com.google.android.gms:play-services:7.8+'

To use the API, it's necessary to have internet connection, I had connection to my ADSL but not resolved DNS. Fixing that problem make my app works

Sometimes detector dependencies are downloaded when the app runs for the first time and not when the app installs. I too faced the same issue, the problem is either your network connection is weak or you don't have enough storage for download say 10% of the total space though it does not take that much space but downloads from Google Play Services does require good amount of storage and don't forget to clear cache(Simple check try to update any application from playstore). Refer this Github thread for more information.

Roshna Omer

Check your storage! make sure it is over 10%

That fixed my problem, and I answered it here too...

https://stackoverflow.com/a/43229272/6914806

Here is what was my case. I was using BarcodeDetector for decoding QR codes from imported images. On 4 my testing devices it was working fine. On one was not reading anything from bitmap. I thought this might be incompatibility with android 5.0 but this was not the case. After hours of investigation I finally noticed that detector.isOperational(); returns false. The reason was:

The first time that an app using barcode and/or face APIs is installed on a device, GMS will download a libraries to the device in order to do barcode and face detection. Usually this is done by the installer before the app is run for the first time.

I had wi-fi off on that testing device. After turning it on and relaunching app, detector became operational and started decoding bitmaps.

SimOn Tibas

you must not forget this:

add this to your AndroidManifest.xml

<application
   android:allowBackup="true"
   android:icon="@mipmap/ic_launcher"
   android:label="@string/app_name"
   android:roundIcon="@mipmap/ic_launcher_round"
   android:supportsRtl="true"
   android:theme="@style/AppTheme">


<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="ocr"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!