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:
- Deleting all data of the Google Play Services: Settings->Apps->Google Play Services->Storage->Manage Space->Clear All Data.
- Update Google Play Services, reboot and have Google Play Store open for like 15mins. Version installed:
20.09.13 (120408-298964066)
. - Low storage check (13GB Free).
- Remove/give permission of the camera to the app & Google Play Services.
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)
Any ideas?
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).