On this page
ML Kit's vision and language APIs use compact, task-specific models. They run in milliseconds, work offline, and keep data on the phone, often making them a better first choice than an LLM. See LLMs vs Traditional ML.
What's available
| API | Does | Example feature |
|---|---|---|
| Text recognition | OCR for Latin, Devanagari, Chinese, Japanese, Korean scripts | Scan receipts, notes |
| Image labeling | General labels (food, plant, dogโฆ) | Auto-tag photos |
| Object detection | Locate and track objects | Visual product search |
| Barcode scanning | 1D/2D codes | QR payments, inventory |
| Face detection, pose, segmentation | Landmarks, body pose, background | Filters, fitness |
| Language ID | Detect text language | Route to translation |
| Translation | Offline translation between many languages | Translate chat messages |
| Entity extraction | Addresses, dates, phone numbers, money | Smart actions in messages |
| GenAI Image Description (beta) | Short descriptions via Gemini Nano | Alt text. See Image Description. |
Some models are bundled with the app (bigger APK, available immediately); others are downloaded via Google Play services (smaller APK, needs a download first). Each API page lists the options.
A camera pipeline
Text recognition from a photo
class TextScanner : AutoCloseable {
private val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
suspend fun scan(context: Context, uri: Uri): String {
val image = InputImage.fromFilePath(context, uri)
return recognizer.process(image).await().text // kotlinx-coroutines-play-services await()
}
override fun close() = recognizer.close()
}Live analysis with CameraX
val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
cameraController.setImageAnalysisAnalyzer(
ContextCompat.getMainExecutor(context),
MlKitAnalyzer(
listOf(recognizer),
ImageAnalysis.COORDINATE_SYSTEM_VIEW_REFERENCED,
ContextCompat.getMainExecutor(context),
) { result ->
result.getValue(recognizer)?.let { text -> viewModel.onTextDetected(text.text) }
},
)Language: ID, translation, entities
suspend fun translateToEnglish(text: String): String {
val lang = LanguageIdentification.getClient().identifyLanguage(text).await()
if (lang == "und" || lang == "en") return text
val sourceLang = TranslateLanguage.fromLanguageTag(lang) ?: return text
val translator = Translation.getClient(
TranslatorOptions.Builder()
.setSourceLanguage(sourceLang)
.setTargetLanguage(TranslateLanguage.ENGLISH)
.build()
)
return translator.use {
it.downloadModelIfNeeded(DownloadConditions.Builder().requireWifi().build()).await()
it.translate(text).await()
}
}
suspend fun findEntities(text: String): List<String> {
val extractor = EntityExtraction.getClient(
EntityExtractorOptions.Builder(EntityExtractorOptions.ENGLISH).build()
)
return extractor.use {
it.downloadModelIfNeeded().await()
it.annotate(text).await().flatMap { a -> a.entities.map { e -> "${e.type}: ${text.substring(a.start, a.end)}" } }
}
}Best practices
- Close detectors when done, and reuse clients during a session.
- Downscale large images before processing to save time and memory.
- Use confidence thresholds, and let users correct results.
- Download language models over Wi-Fi with user-visible progress.
Frequently asked questions
Does ML Kit send images to Google?
The on-device APIs process data locally. Review each API's documentation and your Play Data safety disclosures.
How accurate is on-device translation?
It's good for getting the gist, but less fluent than cloud translation. Label it as automatic translation.
Conclusion
ML Kit gives you OCR, labeling, detection, translation and entity extraction on device: fast, private and free. Combine it with CameraX for live features, and add an LLM only when you need open-ended generation.
Next step: make AI features work across devices and offline with Offline AI Features and Device Compatibility.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
Every AI feature still runs inside an Android app that has to be fast, reliable and well structured. Strengthen the Kotlin, Jetpack Compose and architecture skills that AI integrations depend on, then apply these AI concepts with confidence.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.