專案總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android Studio for Platform (ASfP) 中的專案包含可定義 AOSP 程式碼庫工作區的所有內容,包括原始碼、資產、測試程式碼和建構設定。
當您啟動新專案時,ASfP 會為所有檔案建立必要的結構,並顯示在「Project」視窗中。如要開啟這個視窗,請依序選取「View」>「Tool Windows」>「Project」。
本頁提供專案設定中主要元件的總覽。
專案設定 (.asfp-project
)
ASfP 專案設定是由專案目錄根目錄中的 .asfp-project
檔案控管。這個 YAML 檔案可控制專案內容,以及重要功能的運作方式,因此至關重要。您可以透過主選單開啟,方法是依序選取「ASfP」>「Project」>「Open Config」,或在專案檢視畫面中尋找。
專案建立完成後,系統會根據使用者提供的規格建構設定。您可以隨時編輯設定中的所有參數來修改專案規格,例如更新專案目錄或模組,之後必須同步處理,變更才會生效。
設定參數
您可以在 .asfp-project
檔案中設定下列主要參數:
repo
必要
Android 平台存放區根目錄的絕對路徑。
repo: /path/to/aosp
lunch
必要
與專案搭配使用的午餐目標。這項設定適用於所有 Soong 建構動作,包括同步和相關執行設定。
lunch: your-product-variant-userdebug
directories
選用
要納入或排除在專案中的目錄。這些路徑應是相對於 repo
根目錄的相對路徑。
directories:
include:
- frameworks/base
- packages/apps/Settings
exclude:
- vendor
- out/soong
modules
選用
要納入或排除在專案中的模組。這些項目會與先前指定的 directories
搭配運作。系統支援完整名稱和縮寫名稱。
modules:
include:
- SystemUIGoogle
- frameworks/base/services/core/java:services
exclude:
- UnusedModule
test_sources
選用
ASfP 會嘗試區分正式版和測試來源,但在某些情況下,您可能需要明確標示測試來源。請以相對於 repo
根目錄的路徑提供這些檔案。指定路徑的任何子目錄來源根目錄都會標示為測試。
test_sources:
- cts/tests/tests/example
- tests/mytests
other_languages
選用
Java 支援功能預設為啟用。你可以新增其他語言的支援。
ASfP 也支援 C/C++ (cpp
) 和 Rust (rust
)。
other_languages:
- cpp
- rust
build_config
選用
這個參數可讓您在 Soong 建構事件中新增自訂標記或環境變數。這項設定會套用至 IDE 中導致 Soong 建構的所有動作,包括同步和執行設定。
build_config:
flags:
- -j64
env:
SOONG_ALLOW_MISSING_DEPENDENCIES: true
MY_CUSTOM_VAR: value
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-09-04 (世界標準時間)。
[[["容易理解","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-09-04 (世界標準時間)。"],[],[],null,["A project in Android Studio for Platform (ASfP) contains everything that defines\nyour workspace for your AOSP codebase, from source code and assets to test code\nand build configurations.\n\nWhen you start a new project, ASfP creates the necessary structure for all your\nfiles and makes them visible in the **Project** window. To open the window,\nselect\n**View \\\u003e Tool Windows \\\u003e Project**.\n\nThis page provides an overview of the key components inside your project\nconfiguration.\n\nProject configuration (`.asfp-project`)\n\nThe ASfP project configuration is controlled by the `.asfp-project` file,\nlocated in the root of your project directory. This YAML file is essential for\ncontrolling what goes into your project and how critical features operate. You\ncan open it through the main menu using **ASfP \\\u003e Project \\\u003e Open Config** or by\nfinding it in the project view.\n\nUpon project creation, a config is constructed based on user-provided specs. All\nparameters in the config can be edited at any time to modify the project specs,\nfor example to update project directories or modules, after which a sync is\nrequired for changes to be reflected.\n\nConfiguration parameters\n\nHere are the key parameters you can configure in the `.asfp-project` file:\n\n`repo`\n\n*Required*\n\nAn absolute path to your Android platform repository root. \n\n repo: /path/to/aosp\n\n`lunch`\n\n*Required*\n\nThe lunch target that will be coupled with your project. This is used for all\nSoong build actions, including sync and relevant run configurations. \n\n lunch: your-product-variant-userdebug\n\n`directories`\n\n*Optional*\n\nDirectories to either include in or exclude from your project. These should be\nrelative paths with respect to the `repo` root. \n\n directories:\n include:\n - frameworks/base\n - packages/apps/Settings\n exclude:\n - vendor\n - out/soong\n\n`modules`\n\n*Optional*\n\nModules to either include in or exclude from your project. These work in\nconjunction with the previously specified `directories`. Both full and abridged\nnames are supported. \n\n modules:\n include:\n - SystemUIGoogle\n - frameworks/base/services/core/java:services\n exclude:\n - UnusedModule\n\n`test_sources`\n\n*Optional*\n\nASfP attempts to differentiate between production and test sources, but in some\ncases, you might need to explicitly denote test sources. Provide these as\nrelative paths with respect to the `repo` root. Any source roots that are\nsubdirectories of the specified path(s) will be marked as test. \n\n test_sources:\n - cts/tests/tests/example\n - tests/mytests\n\n`other_languages`\n\n*Optional*\n\nJava support is included by default. You can add support for other languages.\nASfP also supports C/C++ (`cpp`) and Rust (`rust`). \n\n other_languages:\n - cpp\n - rust\n\n`build_config`\n\n*Optional*\n\nThis parameter lets you add custom flags or environment variables to Soong build\nevents. This configuration applies to all actions in the IDE that result in a\nSoong build, including sync and run configurations. \n\n build_config:\n flags:\n - -j64\n env:\n SOONG_ALLOW_MISSING_DEPENDENCIES: true\n MY_CUSTOM_VAR: value"]]