Mengonfigurasi berbagi konteks dengan file .aiexclude
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Jika Anda memilih untuk membagikan konteks project Anda dengan Gemini di Android Studio, Anda dapat mengontrol file mana secara khusus dari codebase yang dibagikan menggunakan file .aiexclude
. Fitur AI di Android Studio tidak dapat mengakses file di luar
project saat ini dan root kontrol versi yang terlampir padanya. Dengan mempertimbangkan hal ini, Anda dapat menempatkan file .aiexclude
di mana saja dalam project dan root VCS-nya untuk mengontrol file mana yang diizinkan untuk diakses oleh fitur AI.
Sama seperti file .gitignore
, file .aiexclude
melacak file yang tidak boleh dibagikan ke Gemini di Android Studio, termasuk pengalaman percakapan serta fitur AI yang beroperasi di editor, seperti penyelesaian kode. File
.aiexclude
beroperasi pada file di atau di bawah direktori yang memuatnya.

Cara menulis file .aiexclude
File .aiexclude
mengikuti sintaksis yang sama dengan
file .gitignore
.
Contoh
Berikut adalah contoh konfigurasi file .aiexclude
:
- Pola
KEYS
memblokir semua file bernama "KEYS" tanpa ekstensi file di atau di bawah direktori yang berisi file .aiexclude
.
KEYS
- Pola
KEYS.*
memblokir semua file bernama "KEYS" dengan ekstensi file apa pun di atau di bawah direktori yang berisi .File aiexclude
.
KEYS.*
- Pola
*.kt
memblokir semua file Kotlin, atau file dengan ekstensi .kt
,
di atau di bawah direktori yang berisi file .aiexclude
.
*.kt
- Pola
/*.kt
memblokir semua file .kt
di direktori .aiexclude
, tetapi tidak di bawahnya.
/*.kt
- Pola
my/sensitive/dir/
memblokir semua file di direktori my/sensitive/dir
dan di bawahnya. Jalur file bersifat relatif terhadap direktori yang berisi
file .aiexclude
.
my/sensitive/dir/
- Pola
my/sensitive/dir/**/.txt
memblokir semua file .txt
di atau di bawah
direktori my/sensitive/dir/
.
my/sensitive/dir/**/.txt
- Pola
my/sensitive/dir/*.txt
memblokir semua file .txt
di direktori
my/sensitive/dir
, tetapi tidak di subdirektori.
my/sensitive/dir/*.txt
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-31 UTC.
[null,null,["Terakhir diperbarui pada 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"]]