页面简介
This guide helps you find the right AI/ML solution for your feature on Android, whether using traditional ML, on-device generative AI (Gemini Nano, ML Kit, LiteRT), cloud-based models (Firebase AI Logic, custom backend), a hybrid approach, or system-level intelligence (AppFunctions).
正文摘录
Android Developers Develop AI Guides Send feedback Find the right AI/ML solution for your feature This guide helps you find the right AI/ML solution for your use case. It provides guidance to help you navigate the various solutions available and choose the one that best fits your needs, given the requirements of the feature you want to implement. In general, when choosing tools and models to implement your AI/ML feature, you should use the simplest model that fulfills your needs. To identify the optimal solution, you need to think through the following: Does the feature need to generate new content (generative AI), or predict or categorize in a deterministic way (traditional ML)? Feature scope: can the task be done entirely within your app (in-app intelligence), or does it require multiple apps to accomplish (system-level intelligence)? Model location: can the task be done offline (on-device model), or does it require interacting with a server (cloud-based model)? Toolkit or model version: how complex is the task, ranging from single-inference tasks to multi-agent orchestration? The following flow chart shows the decision process at a high level: Figure 1. High-level decision process for choosing an AI/ML solution. To inform your decision at each step, refer to sections in the rest of this document. Generative AI versus traditional ML Generative AI models create new content, whereas traditional ML models predict outcomes or categorize data in a completely deterministic manner. If your feature doesn't involve generating new content, then traditional ML solutions might be sufficient. The following table summarizes some traditional ML solutions: Toolkit / Solution Type Primary use case Examples ML Kit SDK On-device Prebuilt vision and natural language processing tasks OCR receipt scannerFast event QR check-insOffline menu translation LiteRT On-device Custom model runtimes Medical image classificationSmart keyboard word prediction for niche subject matter MediaPipe On-device Real-time video or audio stream perception tasks Real-time workout pose coachingFacial filters and effectsHand gesture recognition Google Cloud APIs including Cloud Vision API and Cloud Natural Language API Cloud-based Prebuilt vision and natural language processing tasks Automated video captioningImage quality control and compliance Agent Platform Cloud-based End-to-end custom model training and deployment Specialized image recognition at scaleStock photo search The rest of this document is about generative AI solutions. In-app versus system-level intelligence To identify the best generative AI solution, decide whether your AI feature works entirely within your app or if it requires interacting with other apps or the Android OS, outside of any app. If your feature is triggered by the system, outside of any app, then it counts as system-level intelligence. The following table summarizes the differences between in-app and system-level intelligence features: In-app intelligence System-level intelligence Task scope In-app Across apps (or triggered by the system, outside any app) Tools ML Kit SDK, LiteRT, Firebase AI Logic, or self-hosted backend AppFunctions Use cases Summarize, proofread, or transcribe textDescribe imagesBuild an in-app chatbotGenerate images Build a grocery list in a delivery app based on what you wrote in a notes documentBook a ride to the office and message your coworker your estimated time of arrivalFind a restaurant recommendation in your email inbox and make a reservation In-app intelligence In-app intelligence features don't need to interact with other apps or the system beyond the app. Once you determine that your AI feature is entirely in-app, you need to decide whether you can run the feature completely on-device, use a cloud-based model, or do a hybrid approach that combines both. If you're doing anything that requires video input or tasks that involve multiple agents, then you should use a cloud-based model. The following table compares the capabilities of on-device versus cloud-based models: On-device Cloud Tools ML Kit SDK or LiteRT Firebase AI Logic or self-hosted backend Input type TextImageAudio TextImageAudioVideo Output type Text TextImageAudio User data sensitivity Higher Lower Models GemmaGemini Nano Gemini FlashGemini Flash LiteGemini Pro Use cases Process short content, for example summarize, proofread, or rewrite a short chat message or emailDescribe imagesPersonalize output for users based on their interestsHandle sensitive user dataTranscribe a short audio clip Build a chatbotGenerate imagesTranslate conversations real-timeIn-app photo editingMulti-agent tasks On-device models On-device models are probably preferable if any of the following apply: Cost constraints Feature must be able to run offline Privacy requirements The task at hand is relatively simple—it doesn't require multi-agent orchestration Keep in mind that your users' devices must be able to support on-device models. On-device models typically require more premium devices that can support the local processing. Once you've determined that on-device models are sufficient for your feature, the optimal toolkit or solution depends primarily on the task complexity. The following table summarizes the options for on-device, in-app generative AI tooling: Task complexity Feature characteristics Example Toolkit/Solution Low Single inferencePure generation Summarize text ML Kit SDKLiteRT for fine-tuned models (niche domains) Medium Augmented LLMFunction callingConversation history Query and response ML Kit Prompt API High Single-agent loop, cycling through until task is completed Customer feedback or bug triage ML Kit GenAI Agent API Use the ML Kit Prompt API for straightforward single-turn or multi-turn conversational text generation. When your feature requires autonomous, multi-step execution on-device, use the ML Kit GenAI Agent API. The Agent API supports on-device reasoning loops that can plan, invoke typed tools declared with @AppFunctionDeclaration, persist session context across interactions, and enforce turn limits using maxTurns. Cloud-based models If your feature can't be run entirely on-device, you need to use a cloud-based model. There are two main options for how to use a cloud-based model: Managed backend using Firebase AI Logic. If you're already a Firebase user or want to prototype something relatively quickly, Firebase AI Logic is probably the best solution. Custom backend, or self-hosted server. If you want to use non-Gemini models, have strict privacy requirements, or need to complete a very complex task, you probably need to use a custom backend. We also recommend the following tools for the custom backend setup: Have your custom backend run an agentic framework such as Agent Development Kit Connect the app frontend to the agentic backend using AG-UI Enable agents to generate rich, interactive UIs using A2UI The following table summarizes when to use Firebase AI Logic or a custom backend for cloud-based, in-app generative AI tooling: Task complexity Feature characteristics Example Toolkit/Solution Low Single inferencePure generation Summarize text Firebase AI LogicCustom backend Medium Augmented LLMFunction callingConversation history Query and response Firebase AI LogicCustom backend High Single-agent loop, cycling through until task is completed Customer feedback or bug triage Custom backend Very high Multi-agent orchestration Create an agent team for managing different aspects of a trip Custom backend Hybrid approach Use a hybrid approach when your feature can run locally, but not all of your users have devices that support on-device models and you need to use cloud models as a fallback. For more information, see Hybrid inference. System-level intelligence System-level intelligence lets the Android platform act as a task orchestrator, so AI agents, such as Gemini, can complete user requests across multiple apps and web services. To connect your app with the Android intelligence system, choose an integration method based on whether you want programmatic control or automated UI-driven actions: Integration option Use case AppFunctions Make specific capabilities on your app available for agents to discover and execute on-device. Remote MCP server Make specific capabilities on your app available to integrate directly with the agent's backend. Good for cross-platform development. Computer Control Allows an OEM-preloaded assistant to automate tasks by interacting directly with an app's UI. For more information on system-level intelligence tooling options, see Connect your app to the Android intelligence system. Send feedback Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates. Last updated 2026-11-16 UTC.