我知道有很多类似的问题(here、here或here),但即使我遵循了建议的说明,我仍然面临同样的问题。
即使我似乎正确配置了项目,Firebase ML Kit 似乎在下载设备上文本识别模型时出现问题,给我以下异常:
com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
该项目似乎根据清单中的 DEPENDENCIES 元数据进行了配置,以在打开应用程序(或从 Play 商店下载)时下载依赖项:
<meta-data
android:name="com.google.firebase.ml.vision.DEPENDENCIES"
android:value="ocr" />
以及访问 Internet 和相机的权限:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
:app Gradle 实现了 ML Kit Vision:
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
我也试过:
- 删除 Google Play 服务的所有数据:设置->应用程序->Google Play 服务->存储->管理空间->清除所有数据。
- 更新 Google Play 服务,重新启动并让 Google Play 商店打开 15 分钟。安装版本:
20.09.13 (120408-298964066)
. - 低存储检查(13GB 免费)。
- 删除/授予应用程序和 Google Play 服务的相机权限。
我尝试使用该库的代码在这里(接口的实现ImageAnalysis.Analyzer
):
@SuppressLint("UnsafeExperimentalUsageError")
override fun analyze(imageProxy: ImageProxy) {
Log.d(LOG_TAG, "Trying to detect something")
val mediaImage = imageProxy.image
val imageRotation = degreesToFirebaseRotation(imageProxy.imageInfo.rotationDegrees)
if (mediaImage != null) {
val firebaseImage = FirebaseVisionImage.fromMediaImage(mediaImage, imageRotation)
val detector = FirebaseVision.getInstance().onDeviceTextRecognizer
val result = detector.processImage(firebaseImage)
.addOnSuccessListener { firebaseVisionText ->
// Task completed successfully
Log.d(LOG_TAG, "Text detected! ${firebaseVisionText.text}")
// Close img for next use
imageProxy.close()
}
.addOnFailureListener { e ->
// Task failed with an exception
Log.e(LOG_TAG, e.toString())
e.printStackTrace()
// Close img for next use
imageProxy.close()
}
}
}
它是按照这里的官方说明编写的。
这是完整的输出:
W/izadi.explorat: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
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.
E/OcrAnalyzer: com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
W/System.err: com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
W/System.err: at com.google.android.gms.internal.firebase_ml.zzsc.zzd(com.google.firebase:firebase-ml-vision@@24.0.1:21)
at com.google.android.gms.internal.firebase_ml.zzsc.zza(com.google.firebase:firebase-ml-vision@@24.0.1:39)
at com.google.android.gms.internal.firebase_ml.zzpj.zza(com.google.firebase:firebase-ml-common@@22.0.1:31)
at com.google.android.gms.internal.firebase_ml.zzpl.call(Unknown Source:8)
at com.google.android.gms.internal.firebase_ml.zzpf.zza(com.google.firebase:firebase-ml-common@@22.0.1:32)
at com.google.android.gms.internal.firebase_ml.zzpe.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.google.android.gms.internal.firebase_ml.zze.dispatchMessage(com.google.firebase:firebase-ml-common@@22.0.1:6)
at android.os.Looper.loop(Looper.java:227)
at android.os.HandlerThread.run(HandlerThread.java:67)
有任何想法吗?
有人对我缺少什么或如何解决有任何想法吗?它发生在我的设备(小米米 8 - Android 10)和虚拟设备(Nexus 5X - Android 10 + Play Store)中。