Gemini in Android Studio includes features for every step of the development process. All of the features are also included in Gemini for businesses unless otherwise noted.
Chat
The main interface for interacting with Gemini is the chat window. You can use it to ask questions ranging from very simple and open-ended ones to specific problems that you need help with. See examples of what to ask Gemini.
Code completion
When you opt in to share project context, you can enable AI code completion. When AI code completion is enabled, Gemini offers autocompletion of code that appears as gray italicized text as you type. To learn more, see Code completion.
Code transformation
From the Android Studio code editor, you can prompt Gemini for suggestions on how to modify, optimize, or add code to your app. The suggestions show up as a code diff that you can modify as needed before accepting. To learn more, see Code transformation.
Explain code
Gemini can help explain code to help you quickly understand it. To ask Gemini to explain, highlight the code, right-click and select Gemini > Explain Code. Your query is sent to the main Gemini chat panel, where Gemini can provide a detailed response.
Suggest improvements
Gemini can offer suggestions to help you improve your code so that it follows best practices for Android apps and results in an enhanced user experience. To get suggestions, highlight some code, right-click and select Gemini > Suggest Improvements. Your query is sent to the main Gemini chat panel, where Gemini can provide detailed suggestions.
Multimodal image attachment (preview)
Gemini in Android Studio supports multimodal inputs, which lets you attach images directly to your prompts. Here are some compelling use cases:
- Rapid UI prototyping and iteration: Convert a simple wireframe or high-fidelity mock of your app's UI into working code.
- Diagram explanation and documentation: Gain deeper insights into complex architecture or data flow diagrams by having Gemini explain their components and relationships.
- UI troubleshooting: Capture screenshots of UI bugs and ask Gemini for solutions.
To learn more, see Speed up UI development with image attachment and read the blog post.
File attachment (preview)
Attach code files as context in chat interactions with Gemini in Android Studio. Type @ in the query bar to bring up a file completion menu and select files to attach. To learn more, see the preview release note about Gemini in Android Studio support for file attachments.
Rename variables (preview)
You can get Gemini's suggestions for how to rename variables so that they're more intuitive and descriptive. You can get suggestions for a specific variable through Refactor > Rename or ask Gemini to rethink all the variables in a file or part of a file through Gemini > Rethink variables. To learn more, see Refactor code.
Generate unit test scenarios (preview)
Gemini can help you write unit tests by suggesting test scenarios using the context of the code you want to test. When generating unit test scenarios, Gemini includes detailed names and descriptions for your tests, so that you better understand the intention for each suggested test. To learn more, see Generate unit test scenarios.
Generate documentation (preview)
Use Gemini in Android Studio to generate documentation for your code. When you highlight code and ask Gemini to document it, the suggested documentation shows up in a code diff that you can refine before accepting. To learn more, see Generate documentation.
Generate commit messages (preview)
When committing changes to your version control system from Android Studio, Gemini can use the context from the code changes in the current commit and recent past commits to suggest a detailed commit message. To learn more, see Suggest commit message.
Get help with Build & Sync errors (preview)
Gemini in Android Studio understands Gradle build and sync errors. When errors occur, click the "Ask Gemini" link in the build output to help you diagnose and fix the problems.
Get help with Logcat crashes (preview)
Gemini in Android Studio can help diagnose and troubleshoot crashes at runtime. When a crash occurs, open Logcat and click the "Ask Gemini" link in the Logcat output to help you fix the error.
Get help with App Quality Insights (preview)
Gemini can help explain and suggest fixes for crashes observed in users' devices, reported in App Quality Insights. When you're looking at a stack trace in the App Quality Insights tool window, click Insights to analyze your crash reports and (when possible) recommend next steps and resources to solve the issue. To learn more, see Analyze crash reports.
Generate Compose previews (preview)
Gemini can automatically generate Compose previews to save you time when designing your UI. You can choose to generate a Compose preview for a specific composable or for an entire file. To learn more, see Compose preview generation with Gemini.
Configure context sharing
When you opt in to sharing your project context with Gemini in Android Studio,
you can control which files to exclude from sharing using .aiexclude
files.
Place .aiexclude
files anywhere within the project and its VCS roots to
control which files AI features are allowed to access. To learn more, see
Configure context sharing with .aiexclude files.
Prompt Library (preview)
The Prompt Library lets you save and manage frequently used prompts. Access the Prompt Library from Android Studio > Settings > Gemini > Prompt Library.
Integration with external tools (preview)
Gemini in Android Studio for businesses is integrated with many external tools,
so you can retrieve information and perform actions related to the tools without
needing to leave Android Studio. Type @ to bring up a list of tools
and select one to include in your prompt for Gemini. For example, you can ask
Gemini to list your recent Google docs by typing
"@GoogleDocs
list my recent docs".