Android Setup
Configure expo-ai-kit for Android using Google's ML Kit.
AndroidRequirements
- Expo SDK 54+
- Android API 26+ (minSdkVersion)
- A supported device
Installation
Install expo-ai-kit and the Android build-properties plugin:
npx expo install expo-ai-kit expo-build-propertiesExpo Go is not supported
This package uses native code. Test it in a development build or a production build, not Expo Go.
Configuration
Ensure your app.json includes the minimum SDK version for Android:
{
"expo": {
"plugins": [
[
"expo-build-properties",
{
"android": {
"minSdkVersion": 26
}
}
]
]
}
}After configuring, rebuild your app:
npx expo prebuild --clean
npx expo run:androidAndroid Embeddings (opt-in)
embed() on Android (EmbeddingGemma 300M via MediaPipe TextEmbedder) is gated behind a config-plugin flag — off by default, so apps that don't use embeddings pay zero APK bytes:
{
"expo": {
"plugins": [
["expo-build-properties", { "android": { "minSdkVersion": 26 } }],
["expo-ai-kit", { "androidEmbeddings": true }]
]
}
}- Off (default): the MediaPipe dependency isn't added at prebuild; Android
embed()throws a typedEMBEDDINGS_NOT_ENABLEDerror. - On: ~+25 MB APK (arm64). Requires a new native build (dev client / EAS — an OTA update is not enough).
- The ~184 MB model downloads at runtime via
prepareEmbeddingModel()(SHA-256-verified, stored per-app) —embed()itself never downloads. See the Embeddings guide for the full lifecycle and the Gemma license note.
How It Works
expo-ai-kit uses Google's ML Kit for on-device AI on Android. The model may need to be downloaded on first use on supported devices.
import {
isAvailable,
prepareBuiltInModel,
sendMessage,
} from 'expo-ai-kit';
// Check device support, then make the OS-managed model ready.
const supported = await isAvailable();
if (supported) {
await prepareBuiltInModel();
const response = await sendMessage([
{ role: 'user', content: 'Hello! What can you do?' }
]);
console.log(response.text);
}First Use
isAvailable() checks whether the device supports ML Kit; it does not mean the model asset is ready. On first use,prepareBuiltInModel() downloads the OS-managed model and resolves when inference can begin. Later calls return immediately.
Supported Devices
Not all Android devices support ML Kit. Check Google's supported devices list for compatibility.
Unsupported Devices
On unsupported Android devices, the built-in isAvailable() returns false. If inference is attempted anyway, the library throws a typed DEVICE_NOT_SUPPORTED error rather than returning an empty response.
No ML Kit? Download a model instead
Devices without the ML Kit built-in can still run on-device AI by downloading an open model (Gemma / Qwen / Phi) via LiteRT-LM, RAM permitting. See the Models guide.
Troubleshooting
DEVICE_NOT_SUPPORTED
The device does not support ML Kit. Check the supported devices list.
MODEL_NOT_DOWNLOADED
The device supports ML Kit, but its model is not ready. AwaitprepareBuiltInModel() before retrying inference.
Build errors
Ensure your minSdkVersion is set to 26 or higher in your app.json configuration.
For more troubleshooting help, see the Troubleshooting page.