I know there are many similar questions (here, here or here) but even though I've followed the suggested instructions I'm still facing the same issue.
Even though it seems I have the project configured correctly, the Firebase ML Kit seems to have issues to download the on-device text recognition model giving me the following exception:
com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
The project seems to be configured as required with the DEPENDENCIES metadata in the manifest to download the dependencies upon opening the app (or downloading from the Play Store):
<meta-data
android:name="com.google.firebase.ml.vision.DEPENDENCIES"
android:value="ocr" />
As well as permissions to access the Internet and Cameras:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
The :app Gradle has the implementation of the ML Kit Vision:
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
I've also tried:
20.09.13 (120408-298964066)
.The code where I try to use the library is here (an implementation of the interface 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()
}
}
}
It has been written following the official instructions here.
This is the complete output:
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)
Does someone have any idea on what I'm missing or how to solve it? It happens both in my device (Xiaomi Mi 8 - Android 10) and the virtual device (Nexus 5X - Android 10 + Play Store).
Thanks for your feedback!
The google play service version 20.09.13 that you have is not in our currently supported list for optional module download. Theoretically, we should support all versions that currently in prod after 19.8.31(this will change when new version comes out). I will double check with mu colleague to see why you got 20.08.13 and it is not in the serving list.
In the meantime, could you try to update it again to see if you can get a new version of google play service?
Thanks!
In the end, after trying it in different devices I realised that the issue seemed to be related to how the Google Play Services were installed in the device.
In the original testing device, the Google Play Services were installed as user apps and this apparently prevented the optional module being downloaded. After installing the Play Services at the system level the issue was solved.
TLDR: for the optional modules to be downloaded, Google Play Services need to be installed at system level apparently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With