Litert Runtime
Configures and implements LiteRT (.tflite) on-device inference on Android in Kotlin...
Install
npx skills add android/skills --skill litert-runtime -g -a claude-code -y- Repository
- android/skills10.2k
- Category
- AI and agents
- Updated
- 6d ago
- License
- Complete terms in LICENSE.txt
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
Configures and implements LiteRT (.tflite) on-device inference on Android in Kotlin using the CompiledModel API on CPU and GPU. Use this skill for any Android LiteRT or .tflite task, including Gradle setup, image classification or vision/audio/embedding helpers, TensorBuffer reuse, CPU memory optimization, Bitmap preprocessing, AndroidViewModel GPU-to-CPU fallback with warm-up on a single-thread dispatcher, LiteRT in Google Play services (play-services-litert), migrating from legacy org.tensorflow.lite.Interpreter, GpuDelegate, or play-services-tflite, and latency benchmarking. Don't use for running generative text LLMs with .litertlm files or for Python model conversion.
This skill provides step-by-step guidance for building an Android app that runs
a .tflite model with the LiteRT CompiledModel API
(com.google.ai.edge.litert:litert 2.x; source repository) on the CPU or
the GPU, with the runtime bundled in the APK or from Google Play services. Don't
use the deprecated org.tensorflow.lite.Interpreter API. For
open text language models using .litertlm files, suggest the litert-lm
skill.
Prerequisites
- A Kotlin Android project (
minSdkmust be24or higher, as declared by the LiteRT 2.3.0 AARs). - The runtime that Step 1 picks: the Google Play services runtime (
com.google.android.gms:play-services-litert, the default; see LiteRT in Google Play services), or the bundled runtime (implementation("com.google.ai.edge.litert:litert:2.3.0")andimplementation("com.google.ai.edge.litert:litert-gpu:2.3.0")from Google Maven). For the bundled runtime, from 2.3.0 the GPU accelerator is the second artifact: withlitertalone the app builds, andCompiledModel.createwithCompiledModel.Options(Accelerator.GPU)throwsLiteRtExceptionbecause the APK has no GPU accelerator library. WithCompiledModel.Options(Accelerator.GPU, Accelerator.CPU)it doesn't throw: the model runs on the CPU while the app reports the GPU, and only Logcat shows it (GPU accelerator could not be loaded and registered). No manifest entry is needed:litert-api, whichlitertdepends on, declares the OpenCL driver libraries (uses-native-library) in its own manifest. - A verified
.tflitemodel and its input contract (input dimensions, mean, standard deviation, channel order, and tensor layout). For models with a verified recipe, inspect the LiteRT model recipes.

