.aiexclude ファイルを使用してコンテキスト共有を設定する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android Studio でプロジェクト コンテキストを Gemini と共有することを有効にすると、.aiexclude
ファイルを使用して、コードベースのどのファイルを共有するかを制御できます。Android Studio の AI 機能は、現在のプロジェクトとそれに接続されているバージョン管理ルート以外のファイルにはアクセスできません。このことを念頭に置いて、.aiexclude
ファイルをプロジェクトとその VCS ルート内の任意の場所に配置して、AI 機能がアクセスできるファイルを制御できます。
.gitignore
ファイルと同様に、.aiexclude
ファイルは、チャット エクスペリエンスやエディタで動作する AI 機能(コード補完など)など、Gemini in Android Studio と共有すべきでないファイルを追跡します。.aiexclude
ファイルは、そのファイルを含むディレクトリにあるまたはその下にあるファイルを操作します。

.aiexclude
ファイルを作成する方法
.aiexclude
ファイルの構文は .gitignore
ファイルと同じです。
例
次に .aiexclude
ファイルの構成例を示します。
- パターン
KEYS
は、.aiexclude
ファイルが含まれているディレクトリまたはその下にあるファイル拡張子のない「KEYS」という名前のすべてのファイルをブロックします。
KEYS
- パターン
KEYS.*
は、. を含むディレクトリまたはその下にある、ファイル拡張子を問わず「KEYS」という名前のすべてのファイルをブロックします。aiexclude
ファイル。
KEYS.*
- パターン
*.kt
は、.aiexclude
ファイルを含むディレクトリまたはその下にあるすべての Kotlin ファイル、または拡張子 .kt
のファイルをブロックします。
*.kt
- パターン
/*.kt
は、.aiexclude
ディレクトリ内のすべての .kt
ファイルをブロックしますが、その下のファイルはブロックしません。
/*.kt
- パターン
my/sensitive/dir/
は、my/sensitive/dir
ディレクトリ以下のすべてのファイルをブロックします。ファイルパスは、.aiexclude
ファイルを含むディレクトリを基準とする相対パスです。
my/sensitive/dir/
- パターン
my/sensitive/dir/**/.txt
は、ディレクトリ my/sensitive/dir/
またはその下にあるすべての .txt
ファイルをブロックします。
my/sensitive/dir/**/.txt
- パターン
my/sensitive/dir/*.txt
は、ディレクトリ my/sensitive/dir
内のすべての .txt
ファイルをブロックしますが、サブディレクトリ内のファイルはブロックしません。
my/sensitive/dir/*.txt
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-31 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-31 UTC。"],[],[],null,["# Configure context sharing with .aiexclude files\n\nWhen you opt in to sharing your project context with Gemini in Android Studio,\nyou can control which files specifically from the codebase are shared using\n`.aiexclude` files. AI features in Android Studio cannot access files outside of\nthe current project and the version control roots attached to it. With this in\nmind, you can place `.aiexclude` files anywhere within the project and its VCS\nroots to control which files AI features are allowed to access.\n\nMuch like a `.gitignore` file, an `.aiexclude` file tracks files that shouldn't\nbe shared with Gemini in Android Studio, including the chat experience as well\nas AI features that operate in the editor, like [code completion](/studio/gemini/code-completion). An\n`.aiexclude` file operates on files at or below the directory that contains it.\n\nHow to write `.aiexclude` files\n-------------------------------\n\nAn `.aiexclude` file follow the same syntax as a\n[`.gitignore` file](https://git-scm.com/docs/gitignore).\n\nExamples\n--------\n\nHere are example `.aiexclude` file configurations:\n\n- The pattern `KEYS` blocks all files called \"KEYS\" with no file extension at or below the directory that contains the `.aiexclude` file.\n\n KEYS\n\n- The pattern `KEYS.*` blocks all files called \"KEYS\" with any file extension at or below the directory that contains the .`aiexclude` file.\n\n KEYS.*\n\n- The pattern `*.kt` blocks all Kotlin files, or files with the extension `.kt`, at or below the directory that contains the `.aiexclude` file.\n\n *.kt\n\n- The pattern `/*.kt` blocks all `.kt` files in the `.aiexclude` directory, but not below.\n\n /*.kt\n\n- The pattern `my/sensitive/dir/` blocks all files in the `my/sensitive/dir` directory and below. The file path is relative to the directory that contains the `.aiexclude` file.\n\n my/sensitive/dir/\n\n- The pattern `my/sensitive/dir/**/.txt` blocks all `.txt` files at or below the directory `my/sensitive/dir/`.\n\n my/sensitive/dir/**/.txt\n\n- The pattern `my/sensitive/dir/*.txt` blocks all `.txt` files in the directory `my/sensitive/dir`, but not in sub-directories.\n\n my/sensitive/dir/*.txt"]]