When you opt in to sharing your project context with Gemini in Android Studio,
you can control which files specifically from the codebase are shared using
.aiexclude
files.
Much like a .gitignore
file, an .aiexclude
file tracks files that shouldn't
be shared with Gemini in Android Studio, including the chat experience as well
as AI features that operate in the editor, like intention
actions and code
completion. An .aiexclude
file
operates on files at or below the directory that contains it.
How to write .aiexclude
files
An .aiexclude
file follow the same syntax as a
.gitignore
file.
Examples
Here are example .aiexclude
file configurations:
- The pattern
KEYS
blocks all files called "KEYS" with no file extension at or below the directory that contains the.aiexclude
file.
KEYS
- The pattern
KEYS.
blocks all files called "KEYS" with any file extension at or below the directory that contains the .aiexclude
file.
KEYS.
- The pattern
.kt
blocks all Kotlin files, or files with the extension.kt
, at or below the directory that contains the.aiexclude
file.
.kt
- The pattern
/.kt
blocks all Kotlin files in the.aiexclude
directory, but not below.
/.kt
- The pattern
my/sensitive/dir/
blocks all files in themy/sensitive/dir
directory and below. The file path is relative to the directory that contains the.aiexclude
file.
my/sensitive/dir/
- The pattern
my/sensitive/dir/ /.txt
blocks all.txt files at or below the directorymy/sensitive/dir/
.
my/sensitive/dir/ /.txt
- The pattern
my/sensitive/dir/.txt
blocks all.txt files in the directorymy/sensitive/dir
, but not in sub-directories.
my/sensitive/dir/.txt