Google android 的 ML 套件条码扫描器示例应用无法检测条码

Google ML kit Barcode Scanner example app for android not able to detect barcodes

我正在尝试使用 Google ML 套件条码检测功能。为此,我安装了 google 提供的 this example app。我还将我的应用程序连接到我的一个 firebase 项目。当我打开应用程序并转到该条形码检测中的 LivePreviewActivity 时。相机启动但未检测到条码!。 根据快速入门指南,我还添加了

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

在我的清单文件中。 我也包括了这个

FirebaseVisionBarcodeDetectorOptions options =
            new FirebaseVisionBarcodeDetectorOptions.Builder()
                    .setBarcodeFormats(
                            FirebaseVisionBarcode.FORMAT_CODE_128)
                    .build(); 

在 BarcodeScanningProcessor.java 文件中。

我得到的错误是:

Barcode detection failed com.google.firebase.ml.common.FirebaseMLException: Waiting for the barcode detection model to be downloaded. Please wait.

E/BarcodeNativeHandle: Error Loading module

java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.chimera.DynamiteModuleInitializer"

我已经在华为 Mate 8 和三星 Galaxy S7 Edge 两部手机上安装了这个应用程序。该应用程序无法检测两部手机的条形码。

我的目标是 detect/scan 来自实时相机预览的条形码。 谢谢。

关于第一部分问题"Waiting for the barcode detection model to be downloaded. Please wait.":

如果设备上没有足够的存储空间或设备上没有数据连接,就会发生这种情况。清除 Google 播放服务的数据并重试应该有效:

Settings->Apps->Google Play Services->Storage->Manage Space->Clear All Data

关于 清单中的元数据标签 部分问题:

这有助于生产用例,即当最终用户从 Play 商店安装应用程序时,模型会在安装时使用该元数据标签下载。但是在开发过程中还是需要等待模型下载一次。

关于Dynamite模块加载错误的问题的最后一部分(我还没有足够的声誉来添加评论,所以在这里添加):

你运行是什么Android版本和Google Play服务版本?

添加这个依赖项。它对我有用。

implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'