You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Google ML Kit本地文字识别模型下载等待异常求助

Fixing ML Kit On-device Text Recognition Model Download Stuck Issue

I’ve run into this exact problem before, so here are some practical solutions to get past the "Waiting for the text recognition model to be downloaded" error:

1. Ensure Google Play Services is Up-to-Date

ML Kit depends on Google Play Services to handle model downloads. First, check if the device has the latest version installed. You can add a quick check in your app to prompt users to update if needed:

val playServicesStatus = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(requireContext())
if (playServicesStatus != ConnectionResult.SUCCESS) {
    GoogleApiAvailability.getInstance().getErrorDialog(requireActivity(), playServicesStatus, 9000)?.show()
}

2. Manually Trigger Model Download

The auto-download via the manifest meta-data tag doesn’t always work reliably. Try explicitly requesting the model download and listening for the result:

val textRecognizer = TextRecognition.getClient()
textRecognizer.downloadModelIfNeeded()
    .addOnSuccessListener {
        // Model is ready—start your text recognition here
        performTextRecognition()
    }
    .addOnFailureListener { exception ->
        Log.e("MLKitError", "Model download failed: ${exception.message}", exception)
        // Handle the failure (e.g., show a retry button to users)
    }

3. Double-Check Your Dependencies

Make sure you have the correct ML Kit dependencies in your module-level build.gradle file. Using outdated versions can cause unexpected issues:

// Use the latest stable version of ML Kit Text Recognition
implementation 'com.google.firebase:firebase-ml-vision-text-recognition:24.1.0'

Also, confirm that you’ve applied the Google Services plugin in your project-level build.gradle:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services' // Required for Firebase/ML Kit integration
}

4. Verify Network and Storage

  • The device needs an active internet connection to download the model (even with the pre-download tag, sometimes it requires a post-install connection to trigger the download).
  • Ensure there’s enough free storage space—on-device text recognition models are roughly 200-300MB, so low storage can block the download.

5. Test on a Physical Device

Emulators often have issues with Google Play Services syncing and model downloads. If you’re testing on an emulator, switch to a real Android device with Google Play Services installed.

6. Check Region Availability

Some ML Kit models are restricted in certain regions. Make sure your device’s system region is supported for the on-device text recognition model.


Original Question

I'm integrating Google Machine Learning Kit's On-device text recognition feature into my Android app. I followed the official guide to implement it, but every time I try to detect text, it throws the exception:
"Waiting for the text recognition model to be downloaded. Please wait."

Waiting doesn't help, and retrying after 10 seconds still results in the same error.

I've added the following meta-data tag inside the application tag in my Manifest:

<meta-data android:name="com.google.firebase.ml.vision.DEPENDENCIES" android:value="text" />

This tag is supposed to pre-download the recognition model when the app is installed.

Additional note: I tried the sample app (text-recognition/final) and it has exactly the same issue.

Am I missing a configuration item, or is there an API bug? Any help would be greatly appreciated.

内容的提问来源于stack exchange,提问作者M.Paunov

火山引擎 最新活动