@smileid/usesmileid_mlkit_face
v12.1.1
Published
Android MLKit face detection implementation for the UseSmileID React Native (Expo) SDK.
Downloads
495
Readme
@smileid/usesmileid_mlkit_face
UseSmileID v12 — Google ML Kit face provider for React Native (Expo Modules).
Android-only. Thin shim around the existing native AAR
com.usesmileid:mlkit-face.
Architecture
The native side runs the entire face-scan pipeline (analyzer + validator +
transitioner + state machine). This package contributes a Kotlin Expo Module
that constructs UseSmileIDFaceSession(FaceDetectorAnalyzer()) and a TypeScript
wrapper that bridges the four contract methods (configure / analyze / reset /
close) with Zod-validated wire payloads.
No ML logic is reimplemented in this package — it's a pure passthrough.
Installation
pnpm add @smileid/usesmileid_mlkit_faceExpo's autolinking picks up expo-module.config.json at app build time, but the
build settings the AAR needs belong to the root Gradle project, so add the
package to expo.plugins in app.json and run npx expo prebuild --clean:
{
"expo": {
"plugins": [
[
"@smileid/usesmileid_mlkit_face",
{ "kspVersion": "2.3.6", "additionalModelDependencies": ["barcode_ui"] }
]
]
}
}The plugin pins the Kotlin the AAR was compiled with (2.3.20) and the
androidx.core version that resolves under Expo's Android Gradle Plugin.
It also claims the com.google.mlkit.vision.DEPENDENCIES meta-data on your
<application> with tools:replace: this AAR declares that key as face, so
without the override a second ML Kit consumer declaring its own value (for
instance expo-camera's barcode scanner, which declares barcode_ui) fails the
Android manifest merger. additionalModelDependencies is optional — name the
hints your other consumers declare so their models are prefetched at install
time rather than downloaded on first use.
Expo's own KSP lookup carries no entry for that Kotlin and falls back to a KSP
the compiler cannot load, so pass kspVersion as shown — the samples use
2.3.6. kotlinVersion overrides the Kotlin pin.
Usage
import { useSmileIDMlkitFace } from "@smileid/usesmileid_mlkit_face";
await useSmileIDMlkitFace.configure({
selfieCaptureTimeoutMs: 60_000,
});
const result = await useSmileIDMlkitFace.analyze(bytes, rotation);
// result.state.type === 'found' | 'satisfied' | 'unsatisfied' | …
// result.output.faces[0].score === 0.9
await useSmileIDMlkitFace.close();Cross-platform peers
| Platform | Provider package | Native dep |
| ---------------- | --------------------------------- | ---------------------------- |
| Android | @smileid/usesmileid_mlkit_face | com.usesmileid:mlkit-face |
| Android (no GMS) | @smileid/usesmileid_huawei_face | com.usesmileid:huawei-face |
| iOS | @smileid/usesmileid_vision_face | UseSmileIDVisionFace (SPM) |
Testing
pnpm --filter @smileid/usesmileid_mlkit_face test