diff --git a/README.md b/README.md index 00444dba..671a6f06 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # Google AI SDK for Android -The Google AI client SDK for Android enables developers to use Google's state-of-the-art generative AI models (like Gemini) to build AI-powered features and applications. This SDK supports use cases like: +The Google AI client SDK for Android enables developers to use Google's state-of-the-art generative +AI models (like Gemini) to build AI-powered features and applications. This SDK supports use cases +like: + - Generate text from text-only input - Generate text from text-and-images input (multimodal) - Build multi-turn conversations (chat) -For example, with just a few lines of code, you can access Gemini's multimodal capabilities to generate text from text-and-image input: +For example, with just a few lines of code, you can access Gemini's multimodal capabilities to +generate text from text-and-image input: ```kotlin val generativeModel = GenerativeModel( @@ -15,8 +19,8 @@ val generativeModel = GenerativeModel( val cookieImage: Bitmap = // ... val inputContent = content() { - image(cookieImage) - text("Does this look store-bought or homemade?") + image(cookieImage) + text("Does this look store-bought or homemade?") } val response = generativeModel.generateContent(inputContent) @@ -24,40 +28,53 @@ print(response.text) ``` > [!NOTE] -> If you want to access Gemini on-device (Gemini Nano), check out the [Google AI Edge SDK for Android](https://ai.google.dev/tutorials/android_aicore), which is enabled via Android AICore. +> If you want to access Gemini on-device (Gemini Nano), check out +> the [Google AI Edge SDK for Android](https://ai.google.dev/tutorials/android_aicore), which is +> enabled via Android AICore. ## Try out the sample Android app -This repository contains a sample app demonstrating how the SDK can access and utilize the Gemini model for various use cases. +This repository contains a sample app demonstrating how the SDK can access and utilize the Gemini +model for various use cases. -To try out the sample app you can directly import the project from Android Studio -via **File > New > Import Sample** and searching for *Generative AI Sample* or follow these steps below: +To try out the sample app you can directly import the project from Android Studio +via **File > New > Import Sample** and searching for *Generative AI Sample* or follow these steps +below: -1. Check out this repository.\ -`git clone https://github.com/google/generative-ai-android` +1. Check out this repository.\ + `git clone https://github.com/google/generative-ai-android` -1. [Obtain an API key](https://makersuite.google.com/app/apikey) to use with the Google AI SDKs. +1. [Obtain an API key](https://makersuite.google.com/app/apikey) to use with the Google AI SDKs. -1. Open and build the sample app in the `generativeai-android-sample` folder of this repo. +1. Open and build the sample app in the `generativeai-android-sample` folder of this repo. -1. Paste your API key into the `apiKey` property in the `local.properties` file. +1. Paste your API key into the `apiKey` property in the `local.properties` file. -1. Run the app. +1. Run the app. ## Installation and usage -Add the dependency `implementation("com.google.ai.client.generativeai:generativeai:"`) to your Android project. +Add the dependency `implementation("com.google.ai.client.generativeai:generativeai:"`) to +your Android project. + +For detailed instructions, you can find +a [quickstart](https://ai.google.dev/tutorials/android_quickstart) for the Google AI client SDK for +Android in the Google documentation. -For detailed instructions, you can find a [quickstart](https://ai.google.dev/tutorials/android_quickstart) for the Google AI client SDK for Android in the Google documentation. +This quickstart describes how to add your API key and the SDK's dependency to your app, initialize +the model, and then call the API to access the model. It also describes some additional use cases +and features, like streaming, counting tokens, and controlling responses. -This quickstart describes how to add your API key and the SDK's dependency to your app, initialize the model, and then call the API to access the model. It also describes some additional use cases and features, like streaming, counting tokens, and controlling responses. ## Documentation -Find complete documentation for the Google AI SDKs and the Gemini model in the Google documentation:\ +Find complete documentation for the Google AI SDKs and the Gemini model in the Google +documentation:\ https://ai.google.dev/docs + ## Contributing -See [Contributing](https://github.com/google/generative-ai-android/blob/main/CONTRIBUTING.md) for more information on contributing to the Google AI client SDK for Android. +See [Contributing](https://github.com/google/generative-ai-android/blob/main/CONTRIBUTING.md) for +more information on contributing to the Google AI client SDK for Android. ## License diff --git a/generativeai-android-sample/build.gradle.kts b/generativeai-android-sample/build.gradle.kts index 9a4caa05..6f4017f4 100644 --- a/generativeai-android-sample/build.gradle.kts +++ b/generativeai-android-sample/build.gradle.kts @@ -20,7 +20,7 @@ buildscript { } // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.1.3" apply false + id("com.android.application") version "8.3.1" apply false id("org.jetbrains.kotlin.android") version "1.9.20" apply false id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") version "2.0.1" apply false } diff --git a/generativeai/build.gradle.kts b/generativeai/build.gradle.kts index d78d3079..90e3f681 100644 --- a/generativeai/build.gradle.kts +++ b/generativeai/build.gradle.kts @@ -73,7 +73,7 @@ android { } dependencies { - val ktorVersion = "2.3.2" + val ktorVersion = "2.3.9" implementation("io.ktor:ktor-client-okhttp:$ktorVersion") implementation("io.ktor:ktor-client-core:$ktorVersion") @@ -81,24 +81,24 @@ dependencies { implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion") implementation("io.ktor:ktor-client-logging:$ktorVersion") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3") implementation("androidx.core:core-ktx:1.12.0") implementation("org.slf4j:slf4j-android:1.7.36") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.7.3") - implementation("org.reactivestreams:reactive-streams:1.0.3") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.8.0") + implementation("org.reactivestreams:reactive-streams:1.0.4") implementation("com.google.guava:listenablefuture:1.0") - implementation("androidx.concurrent:concurrent-futures:1.2.0-alpha02") - implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0-alpha02") + implementation("androidx.concurrent:concurrent-futures:1.2.0-alpha03") + implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0-alpha03") testImplementation("junit:junit:4.13.2") - testImplementation("io.kotest:kotest-assertions-core:4.0.7") + testImplementation("io.kotest:kotest-assertions-core:5.8.1") testImplementation("io.kotest:kotest-assertions-jvm:4.0.7") testImplementation("io.ktor:ktor-client-mock:$ktorVersion") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") - dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.8.20") + dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.9.20") } publishing { diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index 279c18c6..413ce8ed 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -55,6 +55,6 @@ gradlePlugin { dependencies { implementation("com.android.tools.build:gradle:8.1.3") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3") implementation("org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin:0.13.2") }