SlideShare a Scribd company logo
Hassan Abid | GDE
What’s new in Android:
Embracing era of
Generative AI
About myself
GDE
- Google Developers Expert for Android
Since 2016
- CTO at BELIVE TECHNOLOGY
- Mentor for AI First Singapore startup
program
- Mentor for Solution Challenge 2023 & 2024
- Speaker at GDG Events across Asia Pacific
(GDG Hanoi 2019)
Agenda
Agenda
Gemini in Android
Studio
01
Gemini SDK For
Android
02
On Device AI
03
Kotlin Multiplatform
04
Link : https://developer.android.com/studio/preview/gemini
Gemini in Android Studio
Android Studio
AI Code Completion Error Explanation and
Fixes
Ask Development
Questions
Key Features
Android Studio
01 02 03
Required for Gemini to use context from Project
Authorize Gemini in
Android Studio
Android Studio
What’s new in Android:  Embracing era of Generative AI
https://developer.android.com/studio/preview/gemini/aiexclude
Configure context sharing
with .aiexclude file
Android Studio
Control
privacy
You can also control the
data that Gemini can
access through a
custom .aiexclude file.
Android Studio
Android Studio
Link : https://developer.android.com/studio/preview/gemini
Demo
Android Studio
- This feature will be available in Android Studio later
this year
- Upload design image, and ask Gemini to generate
compose UI code
- For time being you can use Google AI Studio
https://aistudio.google.com/
Use Google AI Studio to get
Compose code (for UI)
Google AI Studio
Prompt : Act as an Android app developer. For the
image provided, use Jetpack Compose to build the
screen so that the Compose Preview is as close to
this image as possible. Also make sure to include
imports and use Material3."
Code here :
https://gist.github.com/hassanabidpk/80041460aa
20884e6db18411f601a95a
Google AI Studio : link here
Use Google AI Studio to
get Compose code
Example 1
Prompt : Act as an Android app developer. For the
image provided, use Jetpack Compose to build the
screen so that the Compose Preview is as close to
this image as possible. Also make sure to include
imports and use Material3."
Use Google AI Studio to
get Compose code
Example 2
Figma
Design
Code here (CoffeeDetailScreen1.kt):
https://gist.github.com/hassanabidpk/92cf3acf5b9
8d1fdb83e699db115663d
Google AI Studio : link here
UI Correction needed
Generated Code (first
iteration)
Example 2
Iteration 1
result
Prompt : Given this code describing a UI screen
and the image of its Compose Preview, please fix
the part within the red outline so that the items are
at bottom of screen. Buy now button should be on
right side of Price
Correction of UI
Example 2
Highlighted
part
Code here (CoffeeDetailScreen2.kt):
https://gist.github.com/hassanabidpk/92cf3acf5b98d1
fdb83e699db115663d
Google AI Studio : link here
Generated Code (final
iteration)
Example 2
Final result
Integrating
Gemini
prompts in
your app
Visit Prompt Gallery, Try
prompt in AI Studio and
then get code for kotlin
Google AI Studio
Reference
Google IO 24 :
https://android-developers.googleblog.com/2024/05/google-i
o-2024-whats-new-in-android-development-tools.html
Android Studio
https://developer.android.com/studio/run/android-device-streaming
Android Device
Streaming
Device testing
Connect
to devices
anytime
Android Device
Streaming, powered by
Firebase, lets you
securely connect to
remote physical
Android devices hosted
in Google's data
centers.
Device testing
Gemini SDK for Android
Gemini API
Google AI for Android
What’s new in Android:  Embracing era of Generative AI
Gemini API and
Templates
Gemini API
New
Project
Template
You File > New Project.
Select the new Gemini
API starter template.
Gemini API
Setup
App
Gemini API
Generate
API Key
Navigate to Google AI
Studio
https://aistudio.googl
e.com/app/apikey
Gemini API
Demo App
Github :
https://github.com/hassanabidpk/io-extended-2024
Gemini API
How do I make
production-grade
applications on Android?
What’s new in Android:  Embracing era of Generative AI
What’s new in Android:  Embracing era of Generative AI
Link :
https://firebase.google.com/docs/vertex-ai/get-started?platform=android
Get Started with Gemini API
Using Firebase Vertex AI SDK
Firebase Vertex API
Github Repo
Note : Firebase supports upto 20MB payload
Gemini Models use cases and
properties
Firebase Vertex API
What’s new in Android:  Embracing era of Generative AI
What’s new in Android:  Embracing era of Generative AI
Firebase :
https://firebase.google.com/docs/vertex-ai/function-calling?platform=android
Gen AI SDK :
Function Calling
Function Calling
- Function calling makes it easier for you to get
structured data outputs from generative models
- Function calling empowers users to interact with
real-time information and various services, such
as databases, customer relationship management
systems etc.
Why Function Calling?
Function Calling
Android App
getPastOrders()
User Prompt 1 :
What did I order
recently?
Generative
Model
Past orders &
Preferences
- 1 Monday : Latte
- 2 Tuesday : Black
Coffee
- ….
User Prompt 1 :
I am feeling sleepy, order
food to my current
location
Order Summary
- 1 Vietnamese Coffee
with Banh mi
PlaceOrder()
Function Calling
val placeOrderFunction = defineFunction(
"placeOrder",
"Place order of coffee or Tea",
Schema.str("orderSummary", "Type of coffee or tea to
order. Also add any additional food item"),
Schema.str("address", "address to deliver food items")
) { order, address ->
makePlaceOrderApiRequest(order, address)
}
Make API
Request
val generativeModel = GenerativeModel(
modelName = "gemini-1.5-flash",
apiKey = BuildConfig.apiKey,
generationConfig = config,
systemInstruction = content { text(systemInstructions)},
tools = listOf(Tool(listOf(placeOrderFunction,
pastOrdersFunction)))
)
Add multiple
functions
// Check if the model responded with a function call
response.functionCalls.firstOrNull()?.let { functionCall ->
// Try to retrieve the stored lambda from the model's tools and
val matchedFunction = generativeModel.tools?.flatMap { it.functionDeclarations
}
?.first { it.name == functionCall.name }
?: throw InvalidStateException("Function not found: ${functionCall.name}")
// Call the lambda retrieved above
val apiResponse: JSONObject = matchedFunction.execute(functionCall)
// Send the API response back to the generative model
response = chat.sendMessage(
content(role = "function") {
part(FunctionResponsePart(functionCall.name, apiResponse))
}
)
}
Send response
back to
on-going chat
On-Device AI
On Device AI
1. The MediaPipe LLM Inference API (Public beta)
2. Google AI Edge SDK (Private preview)
1. The LLM Inference API lets you
run large language models (LLMs)
completely on-device
2. Features :
a. Text-to-text generation
b. LLM selection
c. LoRA Support
Run Gemma 2B on
Android & iOS
On Device AI
Wrote a poem
about IOX Hanoi
1. Use conversion scripts to format
the model to be compatible with
MediaPipe.
a. E.g : Phi-2, Falcon, or StableLM
b. Non-Kaggle models
2. The model conversion process
requires the MediaPipe PyPI
package
Convert Models to
Mediapipe Format
On Device AI
Google AI Models
Gemini API Cost
Cost
COST (Google
AI Studio)
- Pay-as-you go for
project that has
billing enabled
- Free version (1500
requests per day)
What’s new in Android:  Embracing era of Generative AI
COST
(Firebase)
Firebase : Pay as you
go pricing only
What’s new in Android:  Embracing era of Generative AI
https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-mul
tiplatform-getting-started.html
Kotlin Multiplatform
Multiplatform
https://github.com/hassanabidpk/iox-multiplatform-2024
Kotlin Multiplatform
Demo App
Multiplatform
“At I/O 24 we are excited to
announce we are supporting Kotlin
Multiplatform on Android, which
enables sharing code across mobile,
web, server, and desktop platforms”
Android Dev Rel
What’s new in Android:  Embracing era of Generative AI
1. Use Kotlin Multiplatform for
sharing Business Logic across
mobile and Web
2. Use Flutter for sharing UI and
business Logic across platform
Recommendation from
Google
Multiplatform
Kotlin Multiplatform
Use Compose multi-platform to
share UIs across Android and
iOS Apps
Cross platform Apps
Multiplatform
Install Kotlin Multiplatform Plugin in
Android Studio
https://kmp.jetbrains.com/
Create Kotlin Multiplatform
Project
Multiplatform
- Select new project in Android
Studio → Kotlin Multiplatform
App
Alternatively use
https://kmp.jetbrains.com/
Step-1 Create Kotlin
Multi-platform
project
Multiplatform
- Select Android and iOS Shared UI
implementation using Compose
Multiplatform
- You can download template from
Template gallery too
(Recommended)
Create Kotlin
Multi-platform project
online
Multiplatform
https://kmp.jetbrains.com/
- Project includes two modules
- composeApp
- iOSApp
- The commonMain source set in
composeApp uses the common
Kotlin code, and platform source
sets use Kotlin code specific to
each target
Step-2 Open project
in Android Studio
Multiplatform
In the list of run
configurations, select
composeApp. Choose your
Android virtual / remote or real
device and then click Run.
Step-3a
Run on Android
Multiplatform
Step-3b
Run on iOS
Simulator
Kotlin Multiplatform
- Edit Configuration after
selecting iosApp. Then Run
project
No official Kotlin Multiplatform
SDK available yet. However,
there is an open source library
for KMP
https://github.com/PatilShreyas
/generative-ai-kmp
Let’s integrate Gemini
Multiplatform
- Multiplatform resources [link]
- Lifecycle [link]
- ViewModel [link]
- Navigation and Routing [link]
Official UI Framework
Libraries
Jetbrains
Jetbrains
Multiplatform
- Paging [link]
- sqlite [link]
- room [link]
- datastore [link]
- Samples
https://github.com/android/kotlin-
multiplatform-samples
Official Multiplaform
Libraries (non-UI)
Android
Google
Multiplatform
Samples
Kotlin Multiplatform
https://github.com/topics/kotlin-
multiplatform-sample
https://www.jetbrains.com/help/k
otlin-multiplatform-dev/multipla
tform-samples.html
Summary
Gemini in Android
Studio
01
Gemini SDK For
Android
02
On Device AI
03
Kotlin Multiplatform
04
A. Dependency on cloud-based services
B. Increased latency due to network communication
C. Large Model Size
D. Local processing of sensitive data
What is an advantage of executing a
model on-device?
Quiz
Thank You
Hassan ABID
GDE Android
LinkedIn
Demo code : https://github.com/hassanabidpk/io-extended-2024
Demo Code (Multiplatform) : https://github.com/hassanabidpk/iox-multiplatform-2024
Generative AI Sample (Kotlin) :
https://github.com/google-gemini/generative-ai-android/tree/main/generativeai-android-sample
Generative AI Sample (VertexAI - Firebase Kotlin)
https://github.com/firebase/quickstart-android/tree/master/vertexai
Android 15 features : https://developer.android.com/about/versions/15/features
Gemini Template : https://developer.android.com/studio/preview/gemini-template
Gemini API Tutorial for Android : https://ai.google.dev/gemini-api/docs/get-started/tutorial
Course + Quiz :
https://developers.google.com/learn/pathways/solution-ai-gemini-getting-started-android
References

More Related Content

PPTX
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
PPTX
Raspberry pi and Google Cloud
PDF
How to feature flag and run experiments in iOS and Android
PPTX
End-to-End ML Models Deployment Tutorial
PDF
Dark side of Android apps modularization
PDF
Hacking the Codename One Source Code - Part IV - Transcript.pdf
PDF
Visual Studio Tools for Cordova
PDF
[IO Extended KL] On-Device AI: Is It Time to Go All-In, or Do We Still Need t...
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Raspberry pi and Google Cloud
How to feature flag and run experiments in iOS and Android
End-to-End ML Models Deployment Tutorial
Dark side of Android apps modularization
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Visual Studio Tools for Cordova
[IO Extended KL] On-Device AI: Is It Time to Go All-In, or Do We Still Need t...

Similar to What’s new in Android: Embracing era of Generative AI (20)

PPTX
Nativescript with angular 2
PPTX
Flutter technology Based on Web Development
PPTX
Building Cross-Platform JavaScript Apps using Cordova
PDF
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
PDF
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
PPT
Cross-Platform Mobile Development in Visual Studio
PDF
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
PPT
State ofappdevelopment
PDF
Homestead demo
PDF
Introduction to Cloud Computing with Google Cloud
PPTX
Appium solution artizone
PDF
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
PDF
Getting Started with Android Development
PDF
Recap of Android Dev Summit 2018
PDF
Gitlab ci e kubernetes, build test and deploy your projects like a pro
PPT
Getting started with android studio
PPT
Android
PPT
Android tutorial
PPT
Android tutorial
PPT
Android tutorial
Nativescript with angular 2
Flutter technology Based on Web Development
Building Cross-Platform JavaScript Apps using Cordova
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Cross-Platform Mobile Development in Visual Studio
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
State ofappdevelopment
Homestead demo
Introduction to Cloud Computing with Google Cloud
Appium solution artizone
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
Getting Started with Android Development
Recap of Android Dev Summit 2018
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Getting started with android studio
Android
Android tutorial
Android tutorial
Android tutorial
Ad

More from Hassan Abid (16)

PDF
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
PDF
DevFest SG 2024 - What’s new in On-device Generative AI
PDF
Improving app performance with Kotlin Coroutines
PDF
Android 101 - Kotlin ( Future of Android Development)
PDF
Exploring CameraX from JetPack
PDF
What’s new in Android JetPack
PDF
Kotlin for Android Developers
PDF
Building Modern Apps using Android Architecture Components
PDF
What's new in Android Pie
PDF
Android Jetpack - Google IO Extended Singapore 2018
PDF
Django for mobile applications
PDF
VR Video Apps on Daydream
PDF
Best Practices in Media Playback
PDF
ExoPlayer for Application developers
PPTX
Android n preview
PDF
Introduction to Pakistan
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
DevFest SG 2024 - What’s new in On-device Generative AI
Improving app performance with Kotlin Coroutines
Android 101 - Kotlin ( Future of Android Development)
Exploring CameraX from JetPack
What’s new in Android JetPack
Kotlin for Android Developers
Building Modern Apps using Android Architecture Components
What's new in Android Pie
Android Jetpack - Google IO Extended Singapore 2018
Django for mobile applications
VR Video Apps on Daydream
Best Practices in Media Playback
ExoPlayer for Application developers
Android n preview
Introduction to Pakistan
Ad

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
sap open course for s4hana steps from ECC to s4
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Approach and Philosophy of On baking technology
Spectroscopy.pptx food analysis technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Reach Out and Touch Someone: Haptics and Empathic Computing
MYSQL Presentation for SQL database connectivity
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MIND Revenue Release Quarter 2 2025 Press Release
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The AUB Centre for AI in Media Proposal.docx
“AI and Expert System Decision Support & Business Intelligence Systems”

What’s new in Android: Embracing era of Generative AI