LiteRT, Android’s on-device inference runtime for custom machine learning models, has received a major upgrade with faster GPU inference and smaller app sizes. This change is significant for developers building Android apps that rely on custom ML models, as it simplifies deployment and improves performance.
What LiteRT does
LiteRT handles over a trillion inferences daily across billions of Android devices. It allows developers to run custom ML models directly on the device, which is crucial for tasks like image segmentation, text recognition, and more. Until now, developers had to bundle LiteRT within their apps, which increased the app size and made updates cumbersome.
With the latest update, LiteRT is now integrated into Google Play Services. This means developers no longer need to bundle the runtime with their apps, reducing the app size by approximately 8 MB. This reduction makes apps faster to download and lighter on users' devices.
Faster GPU inference
The new GPU inference in LiteRT runs about 1.4 times faster than the legacy GPU delegate. This performance boost is powered by ML Drift, an open-source GPU engine already used by Google apps on millions of devices daily. The GPU acceleration is available through the new CompiledModel API, which simplifies the process of running models on both CPU and GPU.
Tip
If your app runs custom ML models on CPU or GPU, switching to LiteRT in Google Play Services can provide immediate benefits, including smaller app sizes and faster inference times.
Benefits of using LiteRT in Google Play Services
Developers who adopt LiteRT in Google Play Services enjoy several advantages:
- Smaller apps, more free storage: By not bundling the ML runtime, your app becomes smaller and faster to download.
- Automatic updates: Performance improvements, bug fixes, and security patches are delivered through Play Services, eliminating the need for app updates.
- Broader compatibility: LiteRT now runs on phones back to Android 7 (API level 24), Wear OS 4+, and Android Automotive OS (Android 11+).
- Proven at scale: ML Kit’s Vision and Text APIs, like Subject Segmentation and Document Scanner, already use LiteRT in Google Play Services across billions of devices.
The CompiledModel API
The CompiledModel API is LiteRT’s modern successor to the legacy Interpreter API. It simplifies the workflow for CPU and GPU acceleration, making it easier to deploy models across different hardware configurations. Key features include:
- Simpler: One workflow for CPU and GPU acceleration instead of different delegates for each accelerator.
- Faster: GPU inference runs about 1.4 times faster than the legacy TensorFlow Lite GPU delegate.
- Portable: The same .tflite model runs on Android, iOS, desktop, and web.
- Flexible: The legacy Interpreter API is still supported on CPU, allowing for phased migration.
Getting started with LiteRT
Switching to LiteRT in Google Play Services is straightforward. Here’s how you can get started:
-
Add the dependency: Include
com.google.android.gms:play-services-litert:17.0.0(or a later version) in your project. If you currently bundle LiteRT, remove thelitertdependency. -
Initialize LiteRT: Use the following Kotlin code to initialize LiteRT with GPU enabled:
val liteRtEnvironment = LiteRt.initialize( context, LiteRtDsl.initializationOptions { setEnableGpu(true) } ).await() -
Create your CompiledModel: Pass the LiteRT environment when creating your CompiledModel. The rest of your code remains unchanged.
If you’re already using the legacy Interpreter API in Google Play Services, your existing code will continue to work on CPU. To take advantage of GPU acceleration, migrate to the CompiledModel API.
Migrating with AI assistance
For those using AI coding agents, the new LiteRT skill for Android Studio automates the migration process. In Agent Mode, you can ask it to “migrate my TFLite code to CompiledModel” or type @litert-runtime. The agent will switch your app to play-services-litert, rewrite your Interpreter calls, and set up GPU acceleration with CPU fallback. It can also scaffold a new LiteRT app. Always review the changes, build, and test on a real device.
Deprecation of legacy APIs
The legacy GPU delegate and custom delegate APIs are deprecated in favor of the CompiledModel API. NNAPI will be removed starting in 2027. Older SDKs now receive critical security fixes only. While apps you’ve already shipped will continue to work, it’s essential to plan your migration to the CompiledModel API. Code using deprecated APIs won’t compile against the latest SDK, and staying on an older SDK can cause conflicts as other dependencies move forward.
What’s next for LiteRT
Looking ahead, LiteRT in Google Play Services will continue to evolve, with regular updates including better GPU acceleration and wider model coverage. NPU support in Play Services is also actively being developed.
Read next
- Build Generative UI Apps with A2UI and CopilotKit Agents
- How Agents CLI Helps You Catch and Fix AI Agent Regressions
Want to try all of this hands-on? Start with the free Claude Code from Zero course.
Source
Based on Google Developers Blog’s announcement, “Smaller apps and faster GPU inference with LiteRT in Google Play services”. Written for people learning to build with these tools.