【问题标题】:Google ML kit Barcode Scanner example app for android not able to detect barcodes适用于 android 的 Google ML kit Barcode Scanner 示例应用程序无法检测到条形码
【发布时间】:2018-10-24 20:17:50
【问题描述】:

我正在尝试使用 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 文件中。

我得到的错误是:

条码检测失败 com.google.firebase.ml.common.FirebaseMLException:等待 要下载的条码检测模型。请稍候。

E/BarcodeNativeHandle:加载模块时出错

java.lang.ClassNotFoundException: 找不到类 “com.google.android.gms.chimera.DynamiteModuleInitializer”

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

我的目标是从实时相机预览中检测/扫描条形码。 谢谢。

【问题讨论】:

    标签: android firebase firebase-mlkit


    【解决方案1】:

    关于问题的第一部分“等待条码检测模型下载。请稍候。”

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

    Settings-&gt;Apps-&gt;Google Play Services-&gt;Storage-&gt;Manage Space-&gt;Clear All Data

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

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

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

    您运行的是哪个 Android 版本和 Google Play 服务版本?

    【讨论】:

    • 您可以运行以下命令来查询 Google Play 服务版本。让我们知道结果: adb shell dumpsys 活动服务 com.google.android.gms/.common.stats.GmsCoreStatsService | grep 'com\.google\.android\.gms ['
    • 请注意,在上面的命令中,在 [ 之前还有一个 \,不知何故 StackOverflow 丢弃了那个 \
    • 感谢它可以清除所有数据(仅缓存是不够的)
    • 有没有办法检查模型是否已经下载?
    【解决方案2】:

    添加此依赖项。它对我有用。

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 2019-12-24
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    • 2017-03-13
    • 2020-05-23
    相关资源
    最近更新 更多