Định cấu hình tính năng chia sẻ theo bối cảnh với tệp .aiExclude
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Khi chọn chia sẻ ngữ cảnh dự án với Gemini trong Android Studio, bạn có thể kiểm soát những tệp cụ thể trong cơ sở mã được chia sẻ bằng cách sử dụng các tệp .aiexclude
. Các tính năng AI trong Android Studio không thể truy cập vào các tệp bên ngoài dự án hiện tại và các gốc kiểm soát phiên bản được đính kèm vào dự án đó. Với ý định này, bạn có thể đặt các tệp .aiexclude
ở bất kỳ đâu trong dự án và các gốc VCS của dự án để kiểm soát những tệp mà các tính năng AI được phép truy cập.
Tương tự như tệp .gitignore
, tệp .aiexclude
theo dõi những tệp không được chia sẻ với Gemini trong Android Studio, bao gồm cả trải nghiệm trò chuyện cũng như các tính năng AI hoạt động trong trình chỉnh sửa, chẳng hạn như tính năng hoàn thành mã. Tệp .aiexclude
hoạt động trên các tệp trong hoặc dưới thư mục chứa tệp đó.

Cách viết tệp .aiexclude
Tệp .aiexclude
tuân theo cú pháp giống như tệp .gitignore
.
Ví dụ
Dưới đây là ví dụ về cấu hình tệp .aiexclude
:
- Mẫu
KEYS
chặn tất cả các tệp có tên "KEYS" mà không có đuôi tệp ở hoặc bên dưới thư mục chứa tệp .aiexclude
.
KEYS
- Mẫu
KEYS.*
chặn tất cả các tệp có tên "KEYS" với mọi đuôi tệp tại hoặc bên dưới thư mục chứa .Tệp aiexclude
.
KEYS.*
- Mẫu
*.kt
chặn tất cả các tệp Kotlin hoặc tệp có đuôi .kt
, tại hoặc bên dưới thư mục chứa tệp .aiexclude
.
*.kt
- Mẫu
/*.kt
chặn tất cả các tệp .kt
trong thư mục .aiexclude
, nhưng không chặn các tệp bên dưới.
/*.kt
- Mẫu
my/sensitive/dir/
chặn tất cả các tệp trong thư mục my/sensitive/dir
và các thư mục con. Đường dẫn tệp tương ứng với thư mục chứa tệp .aiexclude
.
my/sensitive/dir/
- Mẫu
my/sensitive/dir/**/.txt
chặn tất cả các tệp .txt
tại hoặc bên dưới thư mục my/sensitive/dir/
.
my/sensitive/dir/**/.txt
- Mẫu
my/sensitive/dir/*.txt
chặn tất cả các tệp .txt
trong thư mục my/sensitive/dir
, nhưng không chặn trong các thư mục con.
my/sensitive/dir/*.txt
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-31 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 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"]]