15

我正在尝试使用 Google Play Services (Vision) 中的新功能将 QR 码扫描添加到我的应用程序中。但是当我运行我的应用程序时,我得到了这个:

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.

我已经按照教程声明了条形码依赖项:

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

我尝试重新安装应用程序并重新启动手机,没有任何帮助。

使用 Google Play Services 7.8,设备上安装的版本为 7.8.11。

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

用于创建条形码检测器的代码:

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;
}

上述关闭返回 false 并完成活动,因为barcodeDetector.isOperational()返回false.

4

7 回答 7

9

Google 已确认他们将很快修复的错误,这会阻止您在某些情况下使用此条形码/面部检测库(链接此处):

  • Mobile Vision 所需的一项服务现在由于该服务中的严重错误而被禁用。这将阻止尚未使用面部或条形码检测的用户使用这些功能。在解决此问题之前,我们不建议您向您的应用添加新的 Mobile Vision 功能。
  • 对于已使用 Mobile Vision 功能的应用,请在使用面部或条形码检测器之前检查 FaceDetector.isOperational() 或 BarcodeDetector.isOperational() 以确认检测器已准备就绪。

它也写在 Google 的 github 示例 repo 上报告的一些问题中:

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

示例(此处):

今天刚刚发布的新版 GMSCore (v9) 存在一个已知问题。

于 2016-05-22T13:13:27.537 回答
6

在我清除缓存并释放一些空间后,它开始工作。我“只有”400mb 可用空间,并且没有错误消息表明这一点。

于 2015-08-20T16:49:30.660 回答
5

基于此处的文档: https ://developers.google.com/android/reference/com/google/android/gms/vision/package-summary 和此处: https ://developers.google.com/android/reference/ com/google/android/gms/vision/Detector#isOperational()

文档:

公共布尔 isOperational()

指示检测器是否具有本地可用的所有必需依赖项以进行检测。

首次安装应用程序时,可能需要下载所需文件。如果返回 false,则这些文件尚不可用。通常在应用程序安装时会处理此下载,但这不能保证。在某些情况下,下载可能会延迟。

如果您的代码添加了处理器,则检测器操作状态的指示也会使用检测器IsOperational() 方法指示。您可以在您的应用程序处理检测结果时对其进行检查,并在适当时将此状态传达给用户。

• 如果检测器可操作,则返回 true,如果依赖项下载正在进行,则返回 false

公共布尔检测器IsOperational()

如果检测器可操作,则返回 true,如果不操作,则返回 false。在非操作情况下,检测器将不返回任何结果。

首次启动应用程序时,如果需要下载以获取进行检测所需的关联库和模型文件,则检测器可能会暂时无法运行。

您的设备似乎需要通过 Google Play 服务完成库的下载,您的应用程序才能立即运行。

基于谷歌示例(源中的评论):

        // 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。爪哇#L156

于 2015-08-19T16:26:39.993 回答
3

我也遇到过这种情况,在我的一个测试设备上找不到视觉库,尽管控制台在每次启动应用程序时都会显示对该库的请求,但从未完成。我在 Nexus 4,5 Motorola X2、Samsung S 2-6 和其他各种设备上进行了测试,S5 是唯一有问题的设备。有足够的可用空间超过 2Gb,在硬重置设备后,扫描立即按预期工作。

于 2015-09-01T14:00:24.083 回答
1

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.

于 2015-10-29T06:15:51.007 回答
1

2020 年 9 月:此版本具有:

implementation 'com.google.android.gms:play-services-vision:20.1.2'
于 2020-09-26T04:44:45.320 回答
0

在 Google Play Services v9.2 中恢复 Mobile Vision 操作 https://developers.google.com/vision/release-notes#google_play_services_92

发行说明

以下是与 Google Play 服务版本相对应的 Mobile Vision API 更新。

谷歌播放服务 9.2

Bug修复

在 Google Play Services v9.2 中恢复了 Mobile Vision 操作。使用新版本的用户将能够下载所需的文件并使用由 Mobile Vision 提供支持的应用程序功能。Google Play 服务更新还包括作为 Mobile Vision 修复的一部分的配置更新。通常这会每隔几天更新一次,但它也会在手机重启时发生(尽管它受到限制,因此不能保证更新配置)。由于文件下载错误仍然可能发生(例如,如果设备上的存储空间不足),我们建议 Google Play 服务开发人员调用 FaceDetector.isOperational() 或 BarcodeDetector.isOperational() 来检查检测器是否准备就绪并相应地降低功能操作。

于 2016-06-29T12:49:16.427 回答