【问题标题】:Google Vision barcode library not found未找到 Google Vision 条码库
【发布时间】:2023-12-21 21:36:01
【问题描述】:

我正在尝试使用 Google Play 服务 (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

【问题讨论】:

  • 你的代码在哪里? build.gradle 的依赖项在哪里?
  • 添加相关依赖和代码
  • 我刚刚遇到了同样的问题,我通过释放设备上的磁盘空间来修复它。它现在很好用,但在此之前,它永远不会下载依赖项。
  • 有人可以帮我解决与 android-vision 相关的类似问题吗? *.com/questions/32715573/…

标签: android google-play-services barcode google-vision android-vision


【解决方案1】:

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

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

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

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

示例 (here):

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

【讨论】:

【解决方案2】:

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

【讨论】:

  • 嗯,这就是我的答案,我必须在我的设备上释放一些空间。
  • 我们有一位用户报告说他有大约 890MB 的免费空间,但仍然没有下载库。你还记得它工作时有多少空间吗?
  • 我遇到了完全相同的问题。我什至实施了低存储检查,但从未通知我存储空间不足。在我删除了一些数据并且我的可用空间仅略高于 10% 后,它立即运行/下载了库。
  • 我不太确定。但是使用最新的库可能会解决这个问题。编译'com.google.android.gms:play-services-vision:9.4.0+'
  • 我得到这个 logcat 资产路径 '/system/framework/com.android.media.remotedisplay.jar' 不存在或不包含资源。
【解决方案3】:

根据此处的文档: 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()

文档:

public boolean isOperational()

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

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

如果您的代码添加了处理器,检测器的指示 检测器IsOperational() 也指示操作状态 方法。您可以在您的应用程序处理检测时检查它 结果,并且可以在适当的情况下将此状态传达给用户。

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

公共布尔检测器IsOperational()

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

在启动应用程序时,检测器可能会在一段时间内无法运行 第一次,如果需要下载获取相关的 检测所需的库和模型文件。

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

基于 Google 示例(源中的注释):

        // 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

【讨论】:

  • 是的,这并不能真正回答问题。我们已经知道了。问题是,很多用户都在使用 Wi-Fi,有大量空闲空间,图书馆仍然拒绝下载。然后对于一些用户来说,几天后他们就可以正常工作了。一个更完整的解释,最好来自谷歌,会很好。
【解决方案4】:

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

【讨论】:

  • 重置设备帮了我
【解决方案5】:

我也有同样的经历。 (抱歉,我无法评论添加我的案例,因为我只有 1 个代表) 我正在使用 Nexus 5 (2013) 和棉花糖 (6.0)。 我从 1gb 的可用空间开始,但没有工作,也没有工作在 2gb。 我最终释放了另外 1gb(所以 3gb 可用空间)然后它工作了。

【讨论】:

    【解决方案6】:

    2020 年 9 月: 这个版本有它:

    implementation 'com.google.android.gms:play-services-vision:20.1.2'
    

    【讨论】:

      【解决方案7】:

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

      发行说明

      以下是 Mobile Vision API 的更新,对应于 Google Play 服务发布。

      Google Play 服务 9.2

      错误修复

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

      【讨论】: