├── .github └── workflows │ └── build-gemini-nano.yml ├── .gitignore ├── .google └── packaging.yaml ├── README.md ├── ai-catalog ├── .gitignore ├── README.md ├── app │ ├── .gitignore │ ├── build.gradle.kts │ ├── google-services.json │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── android │ │ │ └── ai │ │ │ └── catalog │ │ │ ├── CatalogApp.kt │ │ │ ├── MainActivity.kt │ │ │ └── ui │ │ │ ├── CatalogScreen.kt │ │ │ ├── domain │ │ │ └── SampleCatalog.kt │ │ │ └── theme │ │ │ ├── Color.kt │ │ │ ├── Theme.kt │ │ │ └── Type.kt │ │ └── res │ │ ├── drawable │ │ ├── ic_launcher_background.xml │ │ └── ic_launcher_foreground.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ ├── data_extraction_rules.xml │ │ └── provider_paths.xml ├── build.gradle.kts ├── gradle.properties ├── gradle │ ├── libs.versions.toml │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── samples │ ├── gemini-chatbot │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── consumer-rules.pro │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── ai │ │ │ │ └── samples │ │ │ │ └── geminichatbot │ │ │ │ ├── ChatMessage.kt │ │ │ │ ├── GeminiChatbotScreen.kt │ │ │ │ ├── GeminiChatbotViewModel.kt │ │ │ │ └── InputBar.kt │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── gemini-multimodal │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── consumer-rules.pro │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── ai │ │ │ │ └── samples │ │ │ │ └── geminimultimodal │ │ │ │ ├── GeminiMultimodalScreen.kt │ │ │ │ └── GeminiMultimodalViewModel.kt │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── gemini-video-summarization │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── ai │ │ │ │ └── samples │ │ │ │ └── geminivideosummary │ │ │ │ ├── VideoSummarizationScreen.kt │ │ │ │ ├── player │ │ │ │ ├── VideoPlayer.kt │ │ │ │ └── VideoSelectionDropdown.kt │ │ │ │ ├── ui │ │ │ │ ├── OutputTextDisplay.kt │ │ │ │ └── TextToSpeechControls.kt │ │ │ │ ├── util │ │ │ │ └── VideoList.kt │ │ │ │ └── viewmodel │ │ │ │ ├── OutputTextState.kt │ │ │ │ └── VideoSummarizationViewModel.kt │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── genai-image-description │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── consumer-rules.pro │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── ai │ │ │ │ └── samples │ │ │ │ └── genai_image_description │ │ │ │ ├── GenAIImageDescriptionScreen.kt │ │ │ │ └── GenAIImageDescriptionViewModel.kt │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── genai-summarization │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── consumer-rules.pro │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── ai │ │ │ │ └── samples │ │ │ │ └── genai_summarization │ │ │ │ ├── GenAISummarizationScreen.kt │ │ │ │ └── GenAISummarizationViewModel.kt │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── genai-writing-assistance │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── consumer-rules.pro │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── ai │ │ │ │ └── samples │ │ │ │ └── genai_writing_assistance │ │ │ │ ├── GenAIWritingAssistanceScreen.kt │ │ │ │ └── GenAIWritingAssistanceViewModel.kt │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── imagen │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── consumer-rules.pro │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── ai │ │ │ │ └── samples │ │ │ │ └── imagen │ │ │ │ ├── ImagenScreen.kt │ │ │ │ └── ImagenViewModel.kt │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ └── magic-selfie │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── android │ │ │ └── ai │ │ │ └── samples │ │ │ └── magicselfie │ │ │ ├── MagicSelfieScreen.kt │ │ │ └── MagicSelfieViewModel.kt │ │ └── res │ │ └── values │ │ └── strings.xml └── settings.gradle.kts └── gemini-nano ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── google │ │ └── ai │ │ └── edge │ │ └── aicore │ │ └── demo │ │ ├── ContentAdapter.kt │ │ ├── EntryChoiceActivity.kt │ │ ├── GenerationConfigDialog.kt │ │ ├── GenerationConfigUtils.kt │ │ ├── java │ │ └── MainActivity.java │ │ └── kotlin │ │ └── MainActivity.kt │ └── res │ ├── drawable │ ├── list_item_background.xml │ ├── request_item_background.xml │ └── response_item_background.xml │ ├── layout │ ├── activity_entry_choice.xml │ ├── activity_main.xml │ ├── dialog_generation_config.xml │ ├── row_item_request.xml │ └── row_item_response.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── themes.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/workflows/build-gemini-nano.yml: -------------------------------------------------------------------------------- 1 | name: Build Gemini Nano Android App 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ "main" ] 7 | paths: 8 | - 'gemini-nano/**' 9 | pull_request: 10 | branches: [ "main" ] 11 | paths: 12 | - 'gemini-nano/**' 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - name: Checkout code 20 | uses: actions/checkout@v4 21 | 22 | - name: Set up JDK 17 23 | uses: actions/setup-java@v4 24 | with: 25 | java-version: '17' 26 | distribution: 'zulu' 27 | cache: 'gradle' 28 | 29 | - name: Setup Gradle 30 | uses: gradle/actions/setup-gradle@v4 31 | 32 | - name: Make gradlew executable 33 | working-directory: ./gemini-nano 34 | run: chmod +x ./gradlew 35 | 36 | - name: Build Gemini Nano app 37 | working-directory: ./gemini-nano 38 | run: ./gradlew :app:assembleDebug 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | local.properties 2 | .DS_Store 3 | build 4 | /.idea 5 | -------------------------------------------------------------------------------- /.google/packaging.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # This file is used by Google as part of our samples packaging process. 16 | # End users may safely ignore this file. It has no relevance to other systems. 17 | --- 18 | status: PUBLISHED 19 | technologies: [Android] 20 | categories: [Artificial Intelligence] 21 | languages: [Java, Kotlin] 22 | solutions: [Mobile] 23 | github: android/ai-samples 24 | license: apache2 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google AI Samples 2 | 3 | This repository provides a collection of samples showcasing Google AI technologies. 4 | 5 | ## Repository Structure 6 | 7 | The repository is organized into the following folders: 8 | 9 | * [**gemini-nano**](gemini-nano/): This folder contains samples focused on experimenting with 10 | Gemini Nano. You'll find code and resources here to help you explore and utilize Gemini Nano in 11 | your projects. 12 | * [**ai-catalog**](ai-catalog): This folder contains the Android AI Sample app. It demonstrates 13 | various AI capabilities within an Android application. 14 | 15 | ## Getting Started 16 | 17 | To get started with the samples, navigate to the specific folder you're interested in and follow 18 | the instructions within that folder's README.md. 19 | 20 | ## License 21 | 22 | Copyright 2024 Google, Inc. 23 | 24 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 25 | license agreements. See the NOTICE file distributed with this work for 26 | additional information regarding copyright ownership. The ASF licenses this file 27 | to you under the Apache License, Version 2.0 (the "License"); you may not use 28 | this file except in compliance with the License. You may obtain a copy of the 29 | License at 30 | 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | Unless required by applicable law or agreed to in writing, software distributed 34 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 35 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 36 | specific language governing permissions and limitations under the License. 37 | -------------------------------------------------------------------------------- /ai-catalog/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.gradle 3 | /.idea 4 | /.kotlin 5 | app/google-services.json 6 | -------------------------------------------------------------------------------- /ai-catalog/README.md: -------------------------------------------------------------------------------- 1 | # Android AI Sample Catalog 2 | 3 | ![Android AI Sample Catalog screenshots](https://developer.android.com/static/ai/assets/images/ai_sample_catalog_1440.png) 4 | 5 | This folder contains the Android AI Sample catalog, a stand alone application giving you access to 6 | individual self-contained samples illustrating some of the Generative AI capabilities unlocked by 7 | some of Google's models. 8 | 9 | > **Note:** These samples are intended to showcase specific AI capabilities in isolation, and they may use 10 | > simplified code. They are demo not intended to be used as production-ready code. 11 | > For best practices follow our documentation and check 12 | > [Now In Android](https://github.com/android/nowinandroid) 13 | 14 | Browse the samples inside the `/samples` folder: 15 | 16 | - **gemini-chatbot**: a simple chatbot using Gemini 2.0 Flash 17 | - **gemini-multimodal**: a single screen application leveraging text+image to text generation with Gemini 2.0 Flash 18 | - **genai-summarization**: a text summarization sample using Gemini Nano 19 | - **genai-image-description**: an image description sample using Gemini Nano 20 | - **genai-writing-assistance**: a proofreading and rewriting sample using Gemini Nano 21 | - **imagen**: an image generation sample using Imagen 22 | - **magic-selfie**: an sample using ML Kit subject segmentation and Imagen for image generation 23 | - **gemini-video-summarization**: a video summarization sample using Gemini 2.0 Flash 24 | - More to come... 25 | 26 | > **Requires Firebase setup** the samples relying on Google Cloud models (Gemini Pro, Gemini Flash, etc...) 27 | > require setting up a Firebase project and connecting the app to Firebase (read more [here](https://firebase.google.com/docs/ai-logic/get-started?platform=android&api=dev#set-up-firebase)). 28 | 29 | > 🚧 **Work-in-Progress:** we are working on bringing more samples into the application. 30 | 31 | ## How to run 32 | 33 | 1. Clone the repository 34 | 2. Open the whole project in Android Studio. 35 | 3. Set up a Firebase project and connect your app to Firebase by adding your Firebase configuration 36 | file (google-services.json) to the app. Read more [here](https://firebase.google.com/docs/ai-logic/get-started?platform=android&api=dev#set-up-firebase). 37 | 3. Sync & Run `app` configuration 38 | 39 | The app will open with the samples list screen that allows you to navigate throughout the different 40 | available samples. 41 | 42 | ## Reporting issues 43 | 44 | You can report [issues with the samples](https://github.com/android/ai-samples/issues) using 45 | this repository. When doing so, make sure to specify which sample you are referring to. 46 | 47 | ## Contributions 48 | 49 | We aren't open to contribution to this project at the moment. 50 | 51 | ## License 52 | 53 | ``` 54 | Copyright 2023 The Android Open Source Project 55 | 56 | Licensed under the Apache License, Version 2.0 (the "License"); 57 | you may not use this file except in compliance with the License. 58 | You may obtain a copy of the License at 59 | 60 | https://www.apache.org/licenses/LICENSE-2.0 61 | 62 | Unless required by applicable law or agreed to in writing, software 63 | distributed under the License is distributed on an "AS IS" BASIS, 64 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 65 | See the License for the specific language governing permissions and 66 | limitations under the License. 67 | ``` 68 | -------------------------------------------------------------------------------- /ai-catalog/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | google-services.json -------------------------------------------------------------------------------- /ai-catalog/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | plugins { 18 | alias(libs.plugins.android.application) 19 | alias(libs.plugins.jetbrains.kotlin.android) 20 | alias(libs.plugins.jetbrains.kotlin.serialization) 21 | alias(libs.plugins.google.gms.google.services) 22 | alias(libs.plugins.hilt.plugin) 23 | alias(libs.plugins.ksp) 24 | alias(libs.plugins.compose.compiler) 25 | } 26 | 27 | android { 28 | namespace = "com.android.ai.catalog" 29 | compileSdk = 35 30 | 31 | defaultConfig { 32 | applicationId = "com.android.ai.catalog" 33 | minSdk = 26 34 | targetSdk = 35 35 | versionCode = 1 36 | versionName = "1.0" 37 | 38 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 39 | vectorDrawables { 40 | useSupportLibrary = true 41 | } 42 | } 43 | 44 | buildTypes { 45 | release { 46 | isMinifyEnabled = false 47 | proguardFiles( 48 | getDefaultProguardFile("proguard-android-optimize.txt"), 49 | "proguard-rules.pro" 50 | ) 51 | } 52 | } 53 | compileOptions { 54 | sourceCompatibility = JavaVersion.VERSION_17 55 | targetCompatibility = JavaVersion.VERSION_17 56 | } 57 | kotlinOptions { 58 | jvmTarget = "17" 59 | } 60 | buildFeatures { 61 | compose = true 62 | } 63 | } 64 | 65 | dependencies { 66 | 67 | implementation(libs.androidx.core.ktx) 68 | implementation(libs.androidx.lifecycle.runtime.ktx) 69 | implementation(libs.androidx.activity.compose) 70 | implementation(platform(libs.androidx.compose.bom)) 71 | implementation(libs.androidx.ui) 72 | implementation(libs.androidx.ui.graphics) 73 | implementation(libs.androidx.ui.tooling.preview) 74 | implementation(libs.androidx.material3) 75 | implementation(libs.androidx.navigation.compose) 76 | implementation(libs.kotlinx.serialization.json) 77 | implementation(libs.androidx.navigation.runtime.ktx) 78 | implementation(libs.hilt.android) 79 | implementation(libs.hilt.navigation.compose) 80 | implementation(platform(libs.firebase.bom)) 81 | implementation(libs.firebase.ai) 82 | ksp(libs.hilt.compiler) 83 | 84 | implementation(project(":samples:gemini-multimodal")) 85 | implementation(project(":samples:gemini-chatbot")) 86 | implementation(project(":samples:genai-summarization")) 87 | implementation(project(":samples:genai-image-description")) 88 | implementation(project(":samples:genai-writing-assistance")) 89 | implementation(project(":samples:imagen")) 90 | implementation(project(":samples:magic-selfie")) 91 | implementation(project(":samples:gemini-video-summarization")) 92 | 93 | testImplementation(libs.junit) 94 | androidTestImplementation(libs.androidx.junit) 95 | androidTestImplementation(libs.androidx.espresso.core) 96 | androidTestImplementation(platform(libs.androidx.compose.bom)) 97 | androidTestImplementation(libs.androidx.ui.test.junit4) 98 | debugImplementation(libs.androidx.ui.tooling) 99 | debugImplementation(libs.androidx.ui.test.manifest) 100 | } -------------------------------------------------------------------------------- /ai-catalog/app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "NOTE: Replace this file with your own google-services.json. Learn more at: https://firebase.google.com/docs/vertex-ai/get-started#no-existing-firebase", 3 | "project_info": { 4 | "project_number": "123456", 5 | "project_id": "mock_project", 6 | "storage_bucket": "mock_project.firebasestorage.app" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:123456:android:123456", 12 | "android_client_info": { 13 | "package_name": "com.android.ai.catalog" 14 | } 15 | }, 16 | "oauth_client": [], 17 | "api_key": [ 18 | { 19 | "current_key": "123456-abcde" 20 | } 21 | ], 22 | "services": { 23 | "appinvite_service": { 24 | "other_platform_oauth_client": [] 25 | } 26 | } 27 | } 28 | ], 29 | "configuration_version": "1" 30 | } -------------------------------------------------------------------------------- /ai-catalog/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /ai-catalog/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 32 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ai-catalog/app/src/main/java/com/android/ai/catalog/CatalogApp.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.android.ai.catalog 17 | 18 | import android.app.Application 19 | import dagger.hilt.android.HiltAndroidApp 20 | 21 | @HiltAndroidApp 22 | class CatalogApp: Application() -------------------------------------------------------------------------------- /ai-catalog/app/src/main/java/com/android/ai/catalog/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.android.ai.catalog 19 | 20 | import android.os.Bundle 21 | import androidx.activity.ComponentActivity 22 | import androidx.activity.compose.setContent 23 | import androidx.activity.enableEdgeToEdge 24 | import androidx.compose.foundation.layout.fillMaxSize 25 | import androidx.compose.ui.Modifier 26 | import com.android.ai.catalog.ui.CatalogScreen 27 | import com.android.ai.catalog.ui.theme.AISampleCatalogTheme 28 | import dagger.hilt.android.AndroidEntryPoint 29 | 30 | @AndroidEntryPoint 31 | class MainActivity : ComponentActivity() { 32 | override fun onCreate(savedInstanceState: Bundle?) { 33 | super.onCreate(savedInstanceState) 34 | enableEdgeToEdge() 35 | setContent { 36 | AISampleCatalogTheme { 37 | CatalogScreen(modifier = Modifier.fillMaxSize()) 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /ai-catalog/app/src/main/java/com/android/ai/catalog/ui/domain/SampleCatalog.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.android.ai.catalog.ui.domain 19 | 20 | import android.content.Context 21 | import androidx.compose.runtime.Composable 22 | import androidx.compose.ui.graphics.Color 23 | import com.android.ai.catalog.R 24 | import com.android.ai.samples.geminichatbot.GeminiChatbotScreen 25 | import com.android.ai.samples.geminimultimodal.GeminiMultimodalScreen 26 | import com.android.ai.samples.geminivideosummary.VideoSummarizationScreen 27 | import com.android.ai.samples.genai_image_description.GenAIImageDescriptionScreen 28 | import com.android.ai.samples.genai_summarization.GenAISummarizationScreen 29 | import com.android.ai.samples.genai_writing_assistance.GenAIWritingAssistanceScreen 30 | import com.android.ai.samples.imagen.ImagenScreen 31 | import com.android.ai.samples.magicselfie.MagicSelfieScreen 32 | 33 | class SampleCatalog( 34 | context: Context 35 | ) { 36 | 37 | val list = listOf( 38 | SampleCatalogItem( 39 | title = context.getString(R.string.gemini_multimodal_sample_title), 40 | description = context.getString(R.string.gemini_multimodal_sample_description), 41 | route = "GeminiMultimodalScreen", 42 | sampleEntryScreen = { GeminiMultimodalScreen() }, 43 | tags = listOf(SampleTags.GEMINI_2_0_FLASH, SampleTags.FIREBASE), 44 | needsFirebase = true 45 | ), 46 | SampleCatalogItem( 47 | title = context.getString(R.string.gemini_chatbot_sample_title), 48 | description = context.getString(R.string.gemini_chatbot_sample_description), 49 | route = "GeminiChitchatScreen", 50 | sampleEntryScreen = { GeminiChatbotScreen() }, 51 | tags = listOf(SampleTags.GEMINI_2_0_FLASH, SampleTags.FIREBASE), 52 | needsFirebase = true 53 | ), 54 | SampleCatalogItem( 55 | title = context.getString(R.string.genai_summarization_sample_title), 56 | description = context.getString(R.string.genai_summarization_sample_description), 57 | route = "GenAISummarizationScreen", 58 | sampleEntryScreen = { GenAISummarizationScreen() }, 59 | tags = listOf(SampleTags.GEMINI_NANO, SampleTags.ML_KIT) 60 | ), 61 | SampleCatalogItem( 62 | title = context.getString(R.string.genai_image_description_sample_title), 63 | description = context.getString(R.string.genai_image_description_sample_description), 64 | route = "GenAIImageDescriptionScreen", 65 | sampleEntryScreen = { GenAIImageDescriptionScreen() }, 66 | tags = listOf(SampleTags.GEMINI_NANO, SampleTags.ML_KIT) 67 | ), 68 | SampleCatalogItem( 69 | title = context.getString(R.string.genai_writing_assistance_sample_title), 70 | description = context.getString(R.string.genai_writing_assistance_sample_description), 71 | route = "GenAIWritingAssistanceScreen", 72 | sampleEntryScreen = { GenAIWritingAssistanceScreen() }, 73 | tags = listOf(SampleTags.GEMINI_NANO, SampleTags.ML_KIT) 74 | ), 75 | SampleCatalogItem( 76 | title = context.getString(R.string.imagen_sample_title), 77 | description = context.getString(R.string.imagen_sample_description), 78 | route = "ImagenImageGenerationScreen", 79 | sampleEntryScreen = { ImagenScreen() }, 80 | tags = listOf(SampleTags.IMAGEN, SampleTags.FIREBASE), 81 | needsFirebase = true 82 | ), 83 | SampleCatalogItem( 84 | title = context.getString(R.string.magic_selfie_sample_title), 85 | description = context.getString(R.string.magic_selfie_sample_description), 86 | route = "MagicSelfieScreen", 87 | sampleEntryScreen = { MagicSelfieScreen() }, 88 | tags = listOf(SampleTags.IMAGEN, SampleTags.FIREBASE, SampleTags.ML_KIT), 89 | needsFirebase = true 90 | ), 91 | SampleCatalogItem( 92 | title = context.getString(R.string.gemini_video_summarization_sample_title), 93 | description = context.getString(R.string.gemini_video_summarization_sample_description), 94 | route = "VideoSummarizationScreen", 95 | sampleEntryScreen = { VideoSummarizationScreen() }, 96 | tags = listOf(SampleTags.GEMINI_2_0_FLASH, SampleTags.FIREBASE, SampleTags.MEDIA3), 97 | needsFirebase = true 98 | ), 99 | 100 | // To create a new sample entry, add a new SampleCatalogItem here. 101 | ) 102 | 103 | } 104 | 105 | data class SampleCatalogItem( 106 | val title: String, 107 | val description: String, 108 | val route: String, 109 | val sampleEntryScreen: @Composable () -> Unit, 110 | val tags: List = emptyList(), 111 | val needsFirebase: Boolean = false 112 | ) 113 | 114 | enum class SampleTags( 115 | val label: String, 116 | val backgroundColor: Color, 117 | val textColor: Color 118 | ) { 119 | FIREBASE("Firebase", Color(0xFFFF9100), Color.White), 120 | GEMINI_2_0_FLASH("Gemini 2.0 Flash", Color(0xFF4285F4), Color.White), 121 | GEMINI_NANO("Gemini Nano", Color(0xFF7abafe), Color.White), 122 | IMAGEN("Imagen", Color(0xFF7CB342), Color.White), 123 | MEDIA3("Media3", Color(0xFF7CB584), Color.White), 124 | ML_KIT("ML Kit", Color.White, Color(0xFF4285F4)) 125 | } 126 | 127 | -------------------------------------------------------------------------------- /ai-catalog/app/src/main/java/com/android/ai/catalog/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.android.ai.catalog.ui.theme 19 | 20 | import androidx.compose.ui.graphics.Color 21 | 22 | val Purple80 = Color(0xFFD0BCFF) 23 | val PurpleGrey80 = Color(0xFFCCC2DC) 24 | val Pink80 = Color(0xFFEFB8C8) 25 | 26 | val Purple40 = Color(0xFF6650a4) 27 | val PurpleGrey40 = Color(0xFF625b71) 28 | val Pink40 = Color(0xFF7D5260) -------------------------------------------------------------------------------- /ai-catalog/app/src/main/java/com/android/ai/catalog/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.android.ai.catalog.ui.theme 19 | 20 | import android.os.Build 21 | import androidx.compose.foundation.isSystemInDarkTheme 22 | import androidx.compose.material3.MaterialTheme 23 | import androidx.compose.material3.darkColorScheme 24 | import androidx.compose.material3.dynamicDarkColorScheme 25 | import androidx.compose.material3.dynamicLightColorScheme 26 | import androidx.compose.material3.lightColorScheme 27 | import androidx.compose.runtime.Composable 28 | import androidx.compose.ui.platform.LocalContext 29 | 30 | private val DarkColorScheme = darkColorScheme( 31 | primary = Purple80, 32 | secondary = PurpleGrey80, 33 | tertiary = Pink80 34 | ) 35 | 36 | private val LightColorScheme = lightColorScheme( 37 | primary = Purple40, 38 | secondary = PurpleGrey40, 39 | tertiary = Pink40 40 | 41 | /* Other default colors to override 42 | background = Color(0xFFFFFBFE), 43 | surface = Color(0xFFFFFBFE), 44 | onPrimary = Color.White, 45 | onSecondary = Color.White, 46 | onTertiary = Color.White, 47 | onBackground = Color(0xFF1C1B1F), 48 | onSurface = Color(0xFF1C1B1F), 49 | */ 50 | ) 51 | 52 | @Composable 53 | fun AISampleCatalogTheme( 54 | darkTheme: Boolean = isSystemInDarkTheme(), 55 | // Dynamic color is available on Android 12+ 56 | dynamicColor: Boolean = true, 57 | content: @Composable () -> Unit 58 | ) { 59 | val colorScheme = when { 60 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 61 | val context = LocalContext.current 62 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) 63 | } 64 | 65 | darkTheme -> DarkColorScheme 66 | else -> LightColorScheme 67 | } 68 | 69 | MaterialTheme( 70 | colorScheme = colorScheme, 71 | typography = Typography, 72 | content = content 73 | ) 74 | } -------------------------------------------------------------------------------- /ai-catalog/app/src/main/java/com/android/ai/catalog/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.android.ai.catalog.ui.theme 19 | 20 | import androidx.compose.material3.Typography 21 | import androidx.compose.ui.text.TextStyle 22 | import androidx.compose.ui.text.font.FontFamily 23 | import androidx.compose.ui.text.font.FontWeight 24 | import androidx.compose.ui.unit.sp 25 | 26 | // Set of Material typography styles to start with 27 | val Typography = Typography( 28 | bodyLarge = TextStyle( 29 | fontFamily = FontFamily.Default, 30 | fontWeight = FontWeight.Normal, 31 | fontSize = 16.sp, 32 | lineHeight = 24.sp, 33 | letterSpacing = 0.5.sp 34 | ) 35 | /* Other default text styles to override 36 | titleLarge = TextStyle( 37 | fontFamily = FontFamily.Default, 38 | fontWeight = FontWeight.Normal, 39 | fontSize = 22.sp, 40 | lineHeight = 28.sp, 41 | letterSpacing = 0.sp 42 | ), 43 | labelSmall = TextStyle( 44 | fontFamily = FontFamily.Default, 45 | fontWeight = FontWeight.Medium, 46 | fontSize = 11.sp, 47 | lineHeight = 16.sp, 48 | letterSpacing = 0.5.sp 49 | ) 50 | */ 51 | ) -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/ai-catalog/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AI Sample Catalog 3 | Gemini Multimodal Generation 4 | A very simple example of multimodal generation using the Gemini 2.0 Flash model. 5 | Gemini Chatbot 6 | A simple implementation of chatbot using Gemini 2.0 Flash model. 7 | Summarization with Gemini Nano 8 | Summarize articles and conversations on-device with GenAI API powered by Gemini Nano 9 | Image Description with Gemini Nano 10 | Generate short descriptions of images on-device with GenAI API powered by Gemini Nano 11 | Polish text with Gemini Nano 12 | Proofread and rewrite short content on-device with GenAI API powered by Gemini Nano" 13 | Android AI Samples 14 | Open sample 15 | Image generation with Imagen 16 | Generate images with Imagen, Google image generation model 17 | Magic Selfie with Imagen and ML Kit 18 | Change the background of you selfies with Imagen and the ML Kit Segmentation API 19 | Video Summarization with Gemini and Firebase 20 | "Generate a summary of a video (from a cloud URL or Youtube) with Gemini API powered by Firebase" 21 | Firebase Required 22 | This feature requires Firebase to be initialized. 23 | Close 24 | Show me how 25 | -------------------------------------------------------------------------------- /ai-catalog/app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 32 | 33 | -------------------------------------------------------------------------------- /gemini-nano/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 18 | 19 | buildscript { 20 | ext.kotlin_version = '1.9.0' 21 | 22 | repositories { 23 | google() 24 | mavenCentral() 25 | } 26 | dependencies { 27 | classpath 'com.android.tools.build:gradle:8.1.4' 28 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 29 | 30 | // NOTE: Do not place your application dependencies here; they belong 31 | // in the individual module build.gradle files 32 | } 33 | } 34 | 35 | allprojects { 36 | repositories { 37 | google() 38 | mavenCentral() 39 | mavenLocal() 40 | } 41 | } 42 | 43 | tasks.register('clean', Delete) { 44 | delete rootProject.buildDir 45 | } 46 | -------------------------------------------------------------------------------- /gemini-nano/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. For more details, visit 12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true 24 | -------------------------------------------------------------------------------- /gemini-nano/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/ai-samples/2e0c14cccd01b118e7fe41c55551dd310a2d0375/gemini-nano/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gemini-nano/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gemini-nano/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /gemini-nano/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | rootProject.name = "Gemini Nano demo" 18 | include ':app' 19 | --------------------------------------------------------------------------------