Android Studio ML 套件无法加载 OCR 模块

2024-04-08

我正在开发一个涉及 ML 套件的 Android 应用程序。我经历了tutorial https://firebase.google.com/docs/android/setup了解如何设置 Android Studio 以与 Firebase 配合使用。然后我开始使用文本识别 API。这是我在某些按钮单击侦听器中的代码:

        FirebaseVisionTextRecognizer detector = FirebaseVision.getInstance()
            .getOnDeviceTextRecognizer();
        Task<FirebaseVisionText> result = detector.processImage(
            FirebaseVisionImage.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.test))
        )
            .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
                @Override
                public void onSuccess(FirebaseVisionText firebaseVisionText) {
                    System.out.println(firebaseVisionText);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    e.printStackTrace();
                }
            });

我得到以下日志:

W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0
D/TextNativeHandle: Cannot load feature, fall back to load dynamite module.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:0
E/Vision: Error loading module com.google.android.gms.vision.ocr optional module true: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0.
D/TextNativeHandle: Broadcasting download intent for dependency ocr
W/TextNativeHandle: Native handle not yet available. Reverting to no-op handle.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0
D/TextNativeHandle: Cannot load feature, fall back to load dynamite module.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:0
E/Vision: Error loading module com.google.android.gms.vision.ocr optional module true: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0.
W/System.err: com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
        at com.google.android.gms.internal.firebase_ml.zzrw.zzd(com.google.firebase:firebase-ml-vision@@24.0.0:21)
        at com.google.android.gms.internal.firebase_ml.zzrw.zza(com.google.firebase:firebase-ml-vision@@24.0.0:39)
        at com.google.android.gms.internal.firebase_ml.zzpd.zza(com.google.firebase:firebase-ml-common@@22.0.0:31)
        at com.google.android.gms.internal.firebase_ml.zzpf.call(Unknown Source:8)
        at com.google.android.gms.internal.firebase_ml.zzoz.zza(com.google.firebase:firebase-ml-common@@22.0.0:32)
        at com.google.android.gms.internal.firebase_ml.zzoy.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:873)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.google.android.gms.internal.firebase_ml.zze.dispatchMessage(com.google.firebase:firebase-ml-common@@22.0.0:6)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)

我用谷歌搜索看看如何修复这些错误:

W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0
D/TextNativeHandle: Cannot load feature, fall back to load dynamite module.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:0
E/Vision: Error loading module com.google.android.gms.vision.ocr optional module true: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0.
W/System.err: com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.

到目前为止,我已经尝试清除Google Play服务数据(版本19.4.20),重新启动/重新创建模拟器,调整 Gradle 配置(例如添加/删除firebase-core依赖性)。 项目级配置:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用程序模块级配置:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.user.app"
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.gms:play-services-vision:19.0.0'
    implementation 'com.google.firebase:firebase-ml-vision:24.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

apply plugin: 'com.google.gms.google-services'

我决定尝试一下 Barcode API,并添加了

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

作为依赖。令我惊讶的是,当我对其进行 API 调用时,成功监听器被命中并出现以下日志:

I/DynamiteModule: Considering local module com.google.firebase.ml.vision.dynamite.barcode:10000 and remote module com.google.firebase.ml.vision.dynamite.barcode:0
    Selected local version of com.google.firebase.ml.vision.dynamite.barcode
W/is.moneytravel: Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
I/tflite: Initialized TensorFlow Lite runtime.
I/native: barcode_detector_client.cc:222 Not using NNAPI

而 OCR API 仍然产生相同的错误。 我认为它必须处理从中获取库的存储库。 条形码API:

Considering local module com.google.firebase.ml.vision.dynamite.barcode:10000 and remote module com.google.firebase.ml.vision.dynamite.barcode:0

OCR API:

Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0

我对 Gradle 和 Firebase 的经验太少,无法解决这个问题。 为什么 OCR API 是从android.gms,而Barcode API来自firebase.ml?


解决方案是更新 Google Play Services 应用程序。我一开始并没有考虑这是一个选项,因为我希望 API 29 模拟器能够安装最新的 Google Play 服务。我在模拟器上登录Google Play,搜索Google Play Services,卸载它(没有“更新”选项),然后再次安装。它仍然说安装的版本是19.4.20尽管文本识别开始按预期工作。以下是一些相关日志:

W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0
D/TextNativeHandle: Cannot load feature, fall back to load dynamite module.
I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:1
I/DynamiteModule: Selected remote version of com.google.android.gms.vision.ocr, version >= 1
V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android Studio ML 套件无法加载 OCR 模块 的相关文章

  • 在PC上的Firefox上模拟Android的Webview?

    作为我的软件开发工作 针对 Android 的一部分 我需要在通过 Android 的 WebView 查看时检查大量 HTML 页面的内容 到目前为止 我已经能够通过将 HTML 内容转储到文件中来实现这一点 data data
  • 从 Android 联系人中检索名字和姓氏结果为“1”和“null”

    我使用下面的代码从 android 联系人中检索名字和姓氏 DISPLAY NAME 返回联系人的姓名 而名字和姓氏分别返回 1 和 null 以下是代码 ContentResolver cr getContentResolver Curs
  • GCM 卷曲操作超时

    我的服务器上存储了几个负责 GCM 操作的 php 文件 它们似乎在需要时工作得很好 但它们经常返回一个错误 指出 卷曲错误 操作在 0 毫秒后超时 0 中的 0 收到的字节数 这是服务器的问题还是我的 GCM 代码的问题 下面是我的 ph
  • Android 中自定义通知的确切时间

    我正在开发一个用于咨询服务的 Android 应用程序 客户可以在应用程序中查看他们的预约 例如 下次预约 2016 年 12 月 31 日 上午 10 00 现在我需要做的是 用户将收到 2 条通知 有关预约的提醒 7 天前一次 3 天前
  • 三星手机中无法启用闪光灯

    我试图在三星手机中启用闪光灯 但它没有打开 这是我的代码 Camera mycam Camera open Parameters p mycam getParameters p setFlashMode Parameters FLASH M
  • 如何在 Android 中像 Google 地图一样获得持续的位置更新?

    我正在构建一个朋友跟踪 Android 应用程序 当我的朋友激活应用程序并带着他的 GPS 和蜂窝数据离开时 我需要在我的设备上跟踪他 这就是这个概念 我已经实现了 LocationListener 类 现在我可以从 Gps 或网络获取最后
  • Android NSD 未发现所有服务

    我正在尝试使用 Android 本机服务发现来运行应用程序 但有时当我运行该应用程序时 它不会发现我的网络中的所有服务 我正在运行代码https github com joeluchoa nsd https github com joelu
  • MVVMCross 在 MvxBindableListView 中更改 ViewModel

    我的 Android 应用程序出现了一些小问题 我不知道如何使用 MVVM Cross 来解决它 这是我的模型 public class Article string Label get set string Remark get set
  • Android WebView无法正确显示网页

    我有这样的简单 WebView 代码 WebView wv WebView findViewById R id webview1 wv loadUrl http en wikipedia org wiki Book 但显示的页面显示维基百科
  • 如何在首选项标头中使用 PreferenceFragmentCompat

    我正在尝试学习在 Xamarin Android 应用程序中构建首选项页面的方法 我发现了很多 PreferenceFragment 的例子 但它被标记为已弃用 我在现阶段很难重写它们 我创建了代表标题的活动 我添加了 IntentFilt
  • 如何从 ScheduledExecutorService 中删除任务?

    我有一个ScheduledExecutorService定期执行一些不同的任务scheduleAtFixedRate Runnable INIT DELAY ACTION DELAY TimeUnit SECONDS 我也有不一样的Runn
  • Google Checkout 和 Android Market 之间的 API 级别差异是否有记录?

    序言 这个问题已经过时了 不再有 Google Checkout 和 API Android Market 使用 Google Checkout 进行付费应用程序销售 Google Checkout 有相当广泛的 API Android M
  • 主题中的文本外观

    我想将主题中的文本外观设置为 TextAppearnance Large 这是我在 styles xml 中所做的事情 我的应用程序在清单中指向这个主题 问题 我的文字仍然显示很小 问题 我在尝试在活动中使用预定义的 TextAppeara
  • 如何在Android上的Xamarin.Forms中的NavigationBar左侧添加ToolbarItem?

    I need to have关闭button 在本例中 在左侧 of 导航栏 如下 我只需要弹出窗口 因此其他元素 导航不存在潜在问题 谷歌对此有一些建议 但我只看到了 iOS 示例 这并不是一个需要处理的大问题 iOS custom re
  • 带 Retrofit 的 JSON 解析

    我最近开始使用Retrofit 我对此了解不多 我用谷歌搜索了这个问题 但没有答案适合我的问题 这是 JSON 响应 results description eng This is second time testing img url t
  • Android 表单验证 UI 库

    有iOSUS2表单验证器 https github com ustwo US2FormValidator用于用户输入验证的库 见下图 我认为该库比默认情况下在某些内容未验证时弹出警报更好 我正在寻找如何在 Android 上做这样的事情 有
  • 导航抽屉突出显示所选项目不起作用

    我试图突出显示选定的导航抽屉项目 但它不起作用 它仅在按下项目时突出显示 但在选择项目后不会保持突出显示 我有以下代码 列表视图
  • 使用 ProGuard 对 Android 代码进行混淆...如何知道它已被混淆?

    我有一个 Android 项目 最近通过 ProGuard 进行混淆运行后发布到市场 该项目导出时没有任何复杂性 但我怎么知道它已被混淆 我可以做些什么来验证混淆是否成功 寻找dump txt mapping txt seeds txt a
  • android 中的 onSensorChanged 在模拟器中不断触发

    我正在使用 ACCELEROMETER 传感器 并已通过相同的方式注册了一个侦听器 mSensorManager SensorManager getSystemService Context SENSOR SERVICE mAccelera
  • 资源目录不可用

    Eclipse 在问题选项卡中显示资源目录不可用 尽管它在项目文件夹树中可用 2012 09 11 12 14 43 QR01 ERROR resource directory D workspaceQR QR01 res does not

随机推荐

  • 码头服务器配置

    我使用 Jetty 9 但配置有一些问题 我简单的 REST 效果很好 但是当我尝试向所有请求和错误处理程序添加新标头时 问题就开始了 我能够处理标头的唯一方法是将以下代码添加到每个响应中 return Response ok murals
  • 使用Python正确解析PDF段落

    我正在创建一个 Python 脚本 该脚本应该从系统加载一堆 PDF 文件 进行一些数据分析并输出结果 数据分析的本质是 我必须按段落解析 PDF 并且对于每个段落 我必须迭代每个短语 检查是否满足某些条件 我目前正在使用 Tika 进行解
  • 调用对象的多个方法?

    我尝试在单个对象上调用多个函数 但我认为我的语法失败了 你能纠正我吗 objMetaDaten gt setStrTitle test gt setStrBeschreibung test gt setStrUeberschrift tes
  • 如何删除 csv 文件中的整行并将更改保存在同一文件上?

    我是 python 新手 尝试修改 csv 文件 以便我能够根据给定列表删除具有特定字段的特定行 在我当前的代码中 我得到了我想要删除的行 但我无法删除它并将更改保存在同一文件上 替换 import os sys glob import t
  • Laravel 5.3 约束渴望加载不起作用

    我有两个型号User and Profile处于一对一的关系中 我想检索所有用户所在位置profile status TRUE使用以下代码 users User with profile gt function query query gt
  • MATLAB 版本 7 中的 pdist2 等效项

    我需要在matlab中计算两个矩阵之间的欧几里德距离 目前我正在使用 bsxfun 并计算距离 如下所示 我附上代码片段 for i 1 4754 test data fea test i d sqrt sum bsxfun minus t
  • Git RPC 失败;结果=22,HTTP 代码=400

    我在 StackOverflow 上阅读过 发现了与我类似的情况 但没有一个足够接近让我弄清楚下一步应该做什么 我正在尝试提取构建我正在开发的项目 git clone 所需的库的新副本 我发出以下命令 启用 GIT CURL VERBOSE
  • 必要时无法加载 Opencv 库

    我尝试在使用 OpenCV 的必要项目中使用相机 我在 pro 文件中有这个 INCLUDEPATH C OpenCV 2 3 1 android bin OpenCV 2 3 1 include C OpenCV 2 3 1 androi
  • 如何在 jQuery 中触发两个元素的 mouseout 事件?

    假设我有两个独立的 div A 和 B 它们在一个角处重叠 A B 我想在鼠标离开时触发一个事件bothA和B 我试过这个 a b mouseleave function 但如果鼠标离开任一节点 则会触发该事件 我希望一旦鼠标不在任何一个节
  • Zurb Foundation 5:网格列堆叠

    我是基础新手 我只知道如何使用网格的基本概念 I have these 3 columns that need to be stacked see mobile image when viewed on mobile small scree
  • 在 Dart 中不继承静态变量的理由是什么?

    In Dart 如果一个类扩展了另一个类 则扩展类继承所有超类的非静态变量 但不继承其任何静态变量 例如 class TestUpper static final String up super String upup 10 class T
  • “DOM 0 方式”检索 HTML 属性值

    jQuery 有一个attr 检索给定 HTML 属性值的方法 例如 var foo document getElementById foo foo attr id 但是 从性能角度来看 这并不是最佳选择 因为必须创建 jQuery 对象才
  • 在 iOS 应用程序中以编程方式获取崩溃报告

    我想在我的应用程序内访问我的应用程序的崩溃报告 并且我需要将崩溃报告发送到服务器 我在 google 中搜索 找不到任何可以帮助我实现目的的 API 但我发现有一些开源项目 例如 QuincyKit plcrashreporter 用于获取
  • Dart 内部的 wait 到底做了什么?

    我正在开发一个需要使用本地存储的颤振应用程序 由于Android中的文档目录路径将在Future中给出 因此每次我想使用该路径时 我都必须检查future是否完成 代码可能类似于下面 class DataStructure late Fut
  • 使用应用程序脚本更新多个选项卡

    我有一张名为 Main Sheet 的工作表 Col B 中的每个列值都有多个选项卡 东 中 每周都会有新记录添加到主表中 我想要一个谷歌应用程序脚本函数将新行从 Main Sheet 选项卡插入到相应的选项卡 输入表 主表 输出表东方 中
  • 在 R 中使用 knitr 和 markdown 自定义 CSS

    我发现了这个很棒的教程 介绍如何修改在 Rstudio 中使用 markdown 和 knit 创建的 HTML 报告的 css 格式 帖子可以找到here http nsaunders wordpress com 2012 08 27 c
  • Html.BeginForm 外部的提交按钮

    在我的页面上 我有来自母版页的工具栏和一些输入字段 所有输入字段都在标签内form和标签外部的工具栏form 按下外部按钮后是否可以提交表单form tag 请建议 亚历山大 你可以用 JavaScript 来做到这一点
  • ems和像素之间有什么关系?

    em 的像素值是多少 10em px em 和 px 之间没有特定的关系 它是根据每个字体的 m 字符的宽度计算的
  • 添加加载指示器/进度条到 Phonegap Android 闪屏

    我有一个 PhoneGap 1 4 1 jQueryMobile 1 0 1 Android 项目 它显示 res drawable splash png 很好 一旦加载 WebView 闪屏就会消失 我想在启动画面中添加某种进度指示器百分
  • Android Studio ML 套件无法加载 OCR 模块

    我正在开发一个涉及 ML 套件的 Android 应用程序 我经历了tutorial https firebase google com docs android setup了解如何设置 Android Studio 以与 Firebase