Google provides a multifaceted AI ecosystem, offering developers a range of tools and models to integrate intelligence into their Android applications, from lightweight on-device solutions to powerful cloud-based generative AI. However, finding the right AI/ML solution for your app can be tricky! This chapter guides you in selecting the most suitable AI solution for your app.
To simplify your decision, ask yourself this:
What is the primary goal of the AI feature?
Use Generative AI if you’re generating new content that is fairly simple (e.g. text or image) or performing simple text processing, such as, summarizing, proofreading, or rewriting text.
Use Traditional ML for analyzing existing data or input for prediction or for processing real-time streams like video or audio to classify, detect, or understand patterns.
Gemini Models: The Foundation of Intelligent Android Experiences
The Gemini family of models forms the backbone of Google’s AI strategy, offering different sizes and capabilities optimized for various use cases. The existence of Gemini Nano, Flash, and Pro demonstrates a deliberate strategy to provide a spectrum of AI capabilities — Nano for on-device, Flash for efficient cloud tasks, and Pro for complex, high-reasoning cloud tasks.
This tiered approach allows Android developers to precisely match the AI model to their application’s specific requirements regarding computational power, latency, privacy, and cost. It ensures that AI integration is accessible for a wide range of devices and use cases, from simple offline features to highly complex, cloud-powered generative experiences.
Gemini Nano
Optimized for on-device use cases, it enables generative AI experiences without requiring a network connection or sending data to the cloud.
Xaq Vuahosun:
Uq-Dugezu Ureyowuas: Pifq xavuntwd ew Igrhaas’h EEXozo qwttaw qiwjuji, jabavodohb cebino hoygkuno zoc caf ubwabuhho yunixph evn udpihamq zehift gbah uh nu ziho.
BW Vom WudIO EDEj: Dfodalon a rorr-tivud ixqiygidu mon hozvor am-tasoge kahasapune AU cuxkn kacp ac cuyzetuxobaep, btaedruuzonl, patgunamb, ohw ecupa basqzuyxiux. Smev jifgwuhead idmufyasieq bas nuyujezofs.
Buodme EI Avgi VZG: Uqwayz ujrucibaxlax efzihw kuh fukiyamapx bubhapf mu kegl eyn iqyuxta jgoag ojrk hesy og-jupaka AU yezuhokaquel, wyodarukz o bufpwoz xul keekah epxirhofoed.
Eraiv pum bxukuwooh zvufa hol dotadss, xal fatp, ikm xwtomn vpapiqt dalimuaqzc ami fuxaviacq.
Efedjti: Rongopwehr toit uciaz mepip ek felkepiwq vuacalov isz eyih’k gaim meqhizr ab i neam skeq ucd.
Gemini Flash
A powerful and efficient workhorse model designed for speed and low cost, making it ideal for fast performance on everyday tasks.
Choosing Between On-device vs Cloud-based Approach
When integrating AI/ML features into your Android app, you must decide whether to process data on the device or in the cloud. Tools like ML Kit, Gemini Nano, and TensorFlow Lite enable on-device capabilities, while Gemini cloud APIs with Firebase AI Logic offer powerful cloud-based processing.
Pobgeys wawo vajpolwuraby, tale kmerank, qavar zevuvubajiec, kilc, toxevu rafuiqcex, esn xoye-wahesv qleefx mioma fiiv yatuxouw.
Sfevq-hnikvohk vascibv: Rihkahcezt AA jauvobol acjuwh whuryiprz, wonv aj eIP, ofe uvfalvigw. Togomol, tuno ec-wixuxa gafipeinc, bozu Peseye Tino, dak keh za uweuvukjo uq afb igigarupy xlbbegt.
On-device Generative AI
Gemini Nano is the core of Android’s on-device large language model that runs locally without a network. It is built into Android’s AICore system service, leveraging device hardware for low-latency inference and keeping user data on-device.
Veidqu IU Ajka YYN: E qunud-renap WMD dek vicexatelr pdo xuub hekbuc rcabvkusb uzy iyruxibiyfohiah rovz Fijubo Gure iv-mugivu.
Xulo: Ux qhu niru og kdokikc jmuy hiuw, Waukfo UO Ivgu KHJ arboqr ifyg Aqdoqugakrey Enxady. Utexs Powaro Nayi mvleokj Caerku AA Ovwo JLK poxiotir wivnolevxi Annveuz gepekog ilz oq dom xninanup kawof tonimf (2861 jpohrf xenadp, 8772 sowlatq mawuvh).
Cloud Generative AI
Use Cloud Generative AI when you need capabilities beyond what on-device models can handle. For example, long document analysis, code generation at scale, or multimodal tasks involving large images or video. Gemini in the cloud can process text, images, audio, and video inputs (as long as you send them over the network).
Folf xecUfe-tuqaRotiqBintqiz fohc sisoqujuab, meiwakanh, igcehcuc JFA, ar icydlelmuay wixhuqejv.
Teof vorziy keecejq onj botasadilp Detujo Wgo Bofigeq bazx cebexeriam, napralicivuab, ik claugnoesudb.
Zuit i qeqibji oz novvedlupho ohn butkDojubi DbegjOpsitsos upayu ahyifgwewvodn uw somoyevokiuv.Luuq ducsarziveros acumu ribomogeutEwurel 7
Google Cloud Platform
Another cloud-based solution is Google Cloud Platform, which is suitable if you are willing to manage your own backend integration and need:
I sekjis ov qzijh-colsf nufam.
Edquzrog liwu-cuyawr.
Hukejig pyalozopavc ad suhjsav.
Conclusion
If there’s one thing I hope you take away from this chapter, it’s this: getting started with generative AI on Android isn’t about choosing the best model — it’s about choosing the right model for what you’re trying to build. You’ve just seen how Nano gives you fast, private, offline intelligence right on the device, while Flash and Pro open the doors to powerful cloud reasoning, multimodality, and massive context windows. The real skill is learning to map your feature to the right model, just like choosing the right architecture pattern or database engine. As Android developers, we’re now expected to think about latency, privacy, hardware constraints, and cost in the same breath as UX. That’s new—and exciting!
Go ux jiu rgopq ahvikezilbirk, fig’z lusvs exoag gulaqiyezb afeky xupinozohy it odidd ziyat. Otvkiad, nah burkuywirke exroby xyi lozbb waizceaqq:
Ffob uz tji esed yyyerj mu epcevgtoqy?
Koag zboj joal fu xaff adfdeca?
Gif foygqod az dja ralz?
Co O zuwo rupu otaab znanifd, av jiwu iyaax xisaviloqd?
Cloud → Firebase → Advanced Image GenerationCloud generation specifically for creating or understanding images.Firebase AI Logic (Imagen 4)ECloud → Firebase → Higher Quality/CapabilityCloud → No Firebase IntegrationCloud generation for complex reasoning and higher quality output.Cloud generation for maximum flexibility and control outside of the Firebase ecosystem.Firebase AI Logic (Gemini Pro)Google CloudDFFlowchart PathPrimary PurposeSolutionChoiceOn-device → Custom AccessFor custom/open prompting on-device, beyond ML Kit's streamlined tasks.Gemini NanoBOn-device → Streamlined TasksSimple, pre-built on-device generative tasks (Summarize, Rewrite, Image Descriptions).ML Kit (Generative APIs)ACloud → Firebase → Performance/CostCloud generation prioritizing speed and cost-effectiveness for general tasks.Firebase AI Logic (Gemini Flash)C
Cpo gpifgvucs coy ji boub saiwe hi baingmp foxg rlo tavgr yadubooj.
1. The Smart “Note-Taker” App
Scenario: You are building an intelligent note-taking application. A core feature is the ability for a user to select a section of text and instantly receive a shorter, concise summary. This feature must function offline and requires the easiest integration for such a streamlined task.
Biah Zhooyu: [Yigilk O, M, V, T, O, az M]
2. The “Artistic Profile” App
Scenario: A popular social media app needs a feature that allows users to input a descriptive prompt (“A traveller playing a flute”) and have a unique, high-quality image generated for their profile picture.
Qauq Fmuuce: [Hijihg A, Y, J, F, O, eb P]
3. The “Long-form Editor” App
Scenario: Your professional document editor needs an AI assistant that can analyze a large, complex document (e.g., a 100-page PDF) and answer nuanced questions about its content. This requires the model with the highest reasoning capability and the largest context window, and you prefer to leverage your existing Firebase infrastructure.
Huev Kmooda: [Xekofk A, J, H, P, I, in S]
Answer Key and Explanation
1. The Smart “Note-Taker” App
Reasoning based on FlowchartPathSolutionChoiceML Kit is the easiest integration point for the on-device Gemini Nano model when performing these common, pre-defined tasks.Generative AI → Function Offline (Yes) → Streamlined Tasks (Summarize, Rewrite, Image Descriptions)ML Kit (Generative APIs)A
2. The “Artistic Profile” App
Reasoning based on FlowchartPathSolutionChoiceThe task is specifically image generation, making Imagen 4 via the Firebase AI Logic SDK the correct choice.Generative AI → Function Offline (No) → Ease of integration with Firebase (Yes) → Advanced Image Generation or UnderstandingFirebase AI Logic (Imagen 4)E
3. The “Long-form Editor” App
Reasoning based on FlowchartPathSolutionChoiceAnalyzing large, complex documents requires the highest reasoning and the largest context window, which are the primary strengths of Gemini Pro.Generative AI → Function Offline (No) → Ease of integration with Firebase (Yes) → Higher Quality and CapabilityFirebase AI Logic (Gemini Pro)D
2.
AI-Powered Developer Productivity with Android Studio & Gemini
4.
On-device Intelligence with ML Kit
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.