Slide 1

Slide 1 text

Building GenAI Powered Android apps Leveraging Gemini in API in your Android apps Demo By Hashir Rafique LinkedIn: https://www.linkedin.com/in/hashirRafique/

Slide 2

Slide 2 text

About Myself •Senior Software Engineer at ExperLabs •Working from the past 5+ years in mobile app industry. •Expertise in both iOS and Android applications.

Slide 3

Slide 3 text

AI vs GenAI

Slide 4

Slide 4 text

AI vs GenAI • Conventional AI trained for specific inputs and outputs • Trained to perform logical as well as deduction based executions. • Conventional AI prediction based e.g. Predicting weather. • GenAI trained on modals with a wide variety of datasets. • Comes in handy to create content from a creative point of view. • GenAI used to create new content sometimes indistinguishable from human created content.

Slide 5

Slide 5 text

Google Gemini

Slide 6

Slide 6 text

Google Gemini • Google’s very own GenAI Model created with support multi-modal content generation i.e. images, texts, audio, videos etc. • Focused on generating content which resembles more to human created content to provide fluid interactions between human and AI. • Integration with google services to enhance user experience across google’s ecosystem, making life easier for their users. • Different Gemini API Models available

Slide 7

Slide 7 text

Gemini Use Cases

Slide 8

Slide 8 text

Gemini Use Cases • Instant Replies. • Rewrite given Texts from prompts. • Compose new Content from given points. • Summarise content. • Create a story or describe details from a given image. • Prompting Gemini to generate responses.

Slide 9

Slide 9 text

Examples • Google Messages • Pixel Recorder • Gemini in Android Studio

Slide 10

Slide 10 text

Integrating Gemini in an Android app

Slide 11

Slide 11 text

Integrating gemini to our app • 4 Simple Steps Create API Key from Google AI SDK Studio Include Google AI SDK dependencies in our code Integrate Gemini Pro to Kotlin Code Pass the prompt text to get the desired results.

Slide 12

Slide 12 text

GoogleAI SDK ClientID

Slide 13

Slide 13 text

Get GoogleAI SDK Client ID • Head over to https://aistudio.google.com/app/apikey • Generate a client ID against a new project or an existing one:

Slide 14

Slide 14 text

Add Project Dependency

Slide 15

Slide 15 text

Add Project Dependency • Add the SDK Dependency to your project in your build.gradle

Slide 16

Slide 16 text

Version Catalogs Use version catalogs for dependencies

Slide 17

Slide 17 text

Integrate Gemini Pro to Kotlin

Slide 18

Slide 18 text

Integrate Gemini API to Kotlin Initialize the modal by passing the API Key and Desired Modal:

Slide 19

Slide 19 text

Integrate Gemini API to Kotlin Generation Config to add limitation to the response

Slide 20

Slide 20 text

Integrate Gemini API to Kotlin Safety settings in modal generation

Slide 21

Slide 21 text

Integrate Gemini API to Kotlin Call the generate content method in a coroutine to generate results:

Slide 22

Slide 22 text

Integrate Gemini API to Kotlin We can also use the stream method to generate response in chunks

Slide 23

Slide 23 text

Gemini API Template

Slide 24

Slide 24 text

Gemini API Template in Android Studio • Generative AI Template in Android studio for beginners • Requires you to have your API Key • Adds all dependencies by itself • Generates the code for calling the modal API • Gives an initial code to practice prompting response from Gemini

Slide 25

Slide 25 text

Gemini API Template in Android Studio • Create a new Project • Select Gemini API Starter • Recommended to use newer target SDK version for better compatibility

Slide 26

Slide 26 text

Gemini API Template in Android Studio • Add your Google AI SDK API Key to continue

Slide 27

Slide 27 text

Gemini API Template in Android Studio

Slide 28

Slide 28 text

Feel Free to ask any Questions

Slide 29

Slide 29 text

Reachout to me on LinkedIn: https://www.linkedin.com/in/hashirRafique Thank You! “Don't just strive to make things better; strive to make things that matter. The future belongs to those who push boundaries and turn the impossible into reality.”