Stay organized with collections Save and categorize content based on your preferences.

Machine learning (ML) is a programming technique that provides your apps the ability to automatically learn and improve from experience without being explicitly programmed to do so. This is especially well-suited for apps that utilize unstructured data such as images and text, or problems with a large number of parameters such as predicting the winning sports team.

Android supports a wide variety of machine learning tools and methods:

Design guides help you integrate machine learning into your app experience:

When developing ML apps for Android, your main tasks are designing products, implementing inference algorithms, and deploying existing ML models. Depending on your circumstances, you may also retrain existing models or build and train new ones.

Build and Train a Model

Machine learning requires a model that's trained to perform a particular task, like making a prediction, or classifying or recognizing some input. You can select (and possibly customize) an existing model, or build a model from scratch. Model creation and training can be done on a development machine, or using cloud infrastructure.

Explore pre-trained models

TensorFlow Hub contains a large repository of TensorFlow Lite models from Google and the wider research community that are optimized to run on Android. There are two model collections worth highlighting which works well with Android inference tooling:

In addition, other pretrained models are available through ML Kit and Google Cloud. Read more about them in the next section.

Learn how to create your own models with TensorFlow

Firebase AutoML Vision Edge offers a graphical interface for producing custom classifiers.

For a deeper hands-on development experience, you can use these TensorFlow resources:


Inference is the process of using a machine learning model that has already been trained to perform a specific task.

A key decision you’ll face as an Android developer is whether inferencing runs on the device, or uses a cloud service that's accessed remotely. Here are some of the issues you should take into account when making this decision:

IssueOn-device inferenceCloud-based inference
Latency Lower latency enhances the realtime experience Asynchronous communication and available bandwidth can affect latency
Resources The particular device's resources, like processing power and storage, can limit performance Cloud-based resources are more powerful and storage is more plentiful
Offline/Online The ability to operate offline is a plus for running with poor or non-existing network infrastructure A network connection is required
Cost Battery usage, model download time for end users Bandwidth for data transfer for end users, computing charges for developers
Privacy User data never leaves the device Data may leave the device, additional precautions may be necessary

The following table shows the available development options for each kind of inference:

On-device inferenceCloud-based inference

ML Kit

Custom TensorFlow Lite Models

If you have downloaded a model from TensorFlow Hub or have trained an image classifier with TensorFlow Lite Model Maker you can implement it in one of two ways depending on the composition of the input image. If it contains:

For non-image classifier use-cases, refer to the TensorFlow Lite example apps on how to implement custom TensorFlow Lite models in various use cases ranging from Style Transfer to Question and Answer.

Firebase ML

Use AutoML Vision Edge to train your own custom vision model on Google Cloud and run the resulting model on Android

Firebase ML

Google Cloud APIs


Deployment is the process of packaging and updating your ML model for use on Android when doing on-device inference. There are three options available:

Include the model with your Android app
Your model is deployed with your app like any other asset. Updates to the model require updating the app. There are two ways you can add a model to your app:
Provide the model at runtime
This enables you to update your model independently of your app. This also makes A/B testing easier. You can serve your custom model using the Firebase ML Custom Models function or host the model download with your own infrastructure.
A combination of both
It is not unusual for developers to package an initial version of their model with their Android app so that user does not need to wait for their model to download while updating the model to a new version.

For selected pre-trained ML Kit models, namely text recognition and barcode scanning, developers can use the shared model provided by Google Play Services resulting in smaller APK sizes.

Developer Stories

Making the impossible possible

Adding ML to your Android app opens up a new way to build applications that were too difficult to get right in a wide variety of conditions (such as reliable barcode scanning) or that were not even previously possible (for example, image detection and text sentiment).


Lose It! is a weight loss calorie tracker app. It helps you lose weight by logging all the food you eat so you know how many calories you have consumed. Lose It! uses the ML Kit text recognition API to scan nutrition labels to pull in the data when users are entering a new food that isn’t in their library.


PlantVillage helps farmers detect diseases in Cassava Plants. Penn State University and the International Institute of Tropical Agriculture uses their custom TensorFlow models running offline on mobile devices to help farmers detect early sign of plant diseases.


The Fishbrain app provides local fishing maps, forecasts, and connects millions of anglers. Fishbrain uses ML Kit Custom Model to deliver updated custom TensorFlow Lite models.