自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
原始碼控管工具
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如要使用 Android 程式碼,必須同時使用 Git (開放原始碼版本控管系統) 和 Repo (Google 建構的存放區管理工具,可在 Git 上執行)。如要瞭解可執行的常見動作 (例如上傳變更以供審查),請參閱「來源控管工作流程」一文。
Git
Git 可處理分散在多個存放區的大型專案。Android 會使用 Git 進行本機作業,例如本機分支、修訂、差異和編輯。在設定 Android 專案時,其中一項挑戰是決定如何以最佳方式支援外部社群,包括業餘愛好者社群,以及打造大眾市場消費裝置的大型原始設備製造商 (OEM)。我們希望元件可替換,也希望有趣的元件能在 Android 以外的地方獨立運作。我們首先選擇了分散式修訂控制系統,然後縮小範圍,選定 Git。
如要進一步瞭解 Git,請參閱這份 Git 說明文件。
存放區
Repo 會在必要時整合 Git 存放區、將內容上傳至 Gerrit 修訂版本控制系統,並自動執行 Android 開發工作流程的部分作業。
Repo 啟動器提供 Python 指令碼,可初始化結帳程序並下載第二部分,也就是完整的 Repo 工具。Android 原始碼簽出作業會一併提供完整的 Repo 工具。根據預設,這個檔案位於 $SRCDIR/.repo/repo/...
,並接收從下載的 Repo 啟動器轉送的指令。
Repo 不會取代 Git,只是在 Android 的環境中,讓 Git 更容易使用。Repo 會使用資訊清單檔案,將 Git 專案匯總到 Android 超級專案中。您可以將 repo
指令 (可執行的 Python 指令碼) 放在路徑中的任何位置。處理 Android 原始碼檔案時,您可以使用 Repo 進行跨網路作業,例如使用單一 Repo 工作目錄。
在大多數情況下,您可以使用 Git 取代 Repo,或混合使用 Repo 和 Git 指令來形成複雜的指令。不過,使用 Repo 進行基本的跨網路作業,可大幅簡化工作。如要進一步瞭解 Repo,請參閱 Repo 指令參考資料、Repo README、預先上傳 Hook (可在 Repo 中啟用的測試),以及 Android 開放原始碼計畫中的一般文件。
如要從 git-repo-downloads 下載並安裝 Repo Launcher,請參閱「安裝 Repo」。
Gerrit
Gerrit 是一種以網路為基礎的程式碼審查系統,適用於使用 Git 的專案。Gerrit 允許所有授權使用者提交變更,如果通過程式碼審查,系統就會自動合併變更,因此可鼓勵大家更集中使用 Git。此外,Gerrit 還簡化了審查程序,可在瀏覽器中並排顯示變更,並啟用內嵌註解。
Android Gerrit 審查介面位於
android-review.googlesource.com
程式碼導覽介面位於
android.googlesource.com。
Android 程式碼搜尋工具
Android 程式碼搜尋可讓您搜尋 AOSP,不必下載任何內容。您可以使用程式碼搜尋功能查看 Android 開放原始碼計畫的原始碼、在開放原始碼分支之間切換,以及瀏覽交互參照。詳情請參閱 Google Developers 網站的程式碼搜尋文件。
Android Studio 是 Android 應用程式的官方整合開發環境 (IDE),專供開發 Android 應用程式使用。
Android Debug Bridge (ADB) 可讓您將開發工作站直接連線至 Android 裝置,以便安裝套件及評估變更。
如要進行 AOSP 開發,請使用 Android Studio for Platform (ASfP)。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-13 (世界標準時間)。
[[["容易理解","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-08-13 (世界標準時間)。"],[],[],null,["# Source control tools\n\nWorking with Android code requires using both **Git** (an open-source\nversion-control system) and **Repo** (a Google-built\nrepository-management tool that runs on top of Git). See\n[Source control workflow](/docs/setup/create/coding-tasks) for a summary of\nregular actions you can take, such as uploading changes for review.\n\nGit\n---\n\nGit handles large projects that are distributed over multiple repositories.\nAndroid uses Git for local operations such as local branching, commits,\ndiffs, and edits. One of the challenges in setting up the Android project\nwas determining how to best support the outside community---from the hobbyist\ncommunity to the large OEMs building mass-market consumer devices. We\nwanted components to be replaceable, and wanted interesting components to\nhave a life of their own, outside of Android. We first chose a distributed\nrevision control system, then narrowed it down to Git.\n\nFor more details on Git, refer to this [Git Documentation](https://git-scm.com/doc).\n\nRepo\n----\n\n[Repo](https://gerrit.googlesource.com/git-repo/+/refs/heads/main/README.md)\nunifies Git repositories when necessary, performs uploads to the [Gerrit\nrevision control system](https://android-review.googlesource.com/), and\nautomates parts of the Android development workflow.\n\nThe Repo Launcher provides a Python script that initializes a checkout and\ndownloads the second part, the full Repo tool. The full Repo tool is\nincluded in an Android source code checkout. It's located, by default, in\n`$SRCDIR/.repo/repo/...` and it receives forwarded commands from the\ndownloaded Repo Launcher.\n\nRepo doesn't replace Git, it only makes it easier to work with Git in the\ncontext of Android. Repo uses [manifest files](https://gerrit.googlesource.com/git-repo/+/main/docs/manifest-format.md)\nto aggregate Git projects into the Android superproject. You can put the\n`repo` command, which is an executable Python script, anywhere in your\npath. In working with the Android source files, you can use Repo for\nacross-network operations such as with a single Repo working directory.\n\nIn most situations, you can use Git instead of Repo, or mix Repo and Git\ncommands to form complex commands. However, using Repo for basic\nacross-network operations makes your work much simpler. For more details\non Repo, see [Repo command reference](/docs/setup/reference/repo),\n[Repo README](https://gerrit.googlesource.com/git-repo/+/refs/heads/main/README.md),\n[Preupload Hooks](https://android.googlesource.com/platform/tools/repohooks/+/refs/heads/android16-release/README.md)\n(tests that can be enabled in Repo), and [general docs in AOSP](https://gerrit.googlesource.com/git-repo/+/main/docs/).\n\nTo download and install the **Repo Launcher** from *git-repo- downloads* ,\nsee [Install Repo](/docs/setup/start/requirements#repo).\n\nGerrit\n------\n\n[Gerrit](https://gerrit-review.googlesource.com/Documentation/) is a\nweb-based code review system for projects that use Git. Gerrit encourages a\nmore centralized use of Git by allowing all authorized users to submit\nchanges, which are automatically merged if they pass code review. In\naddition, Gerrit simplifies reviewing, displaying changes side by side in\nthe browser and enabling inline comments.\n\nFind the Android Gerrit review interface at\n[android-review.googlesource.com](https://android-review.googlesource.com/)\nand the code navigation interface at\n[android.googlesource.com](https://android.googlesource.com/).\n\nAndroid Code Search\n-------------------\n\n[Android Code Search](https://cs.android.com) lets you search AOSP without\ndownloading anything. You can use Code Search to view the AOSP source code,\nswitch between open source branches, and navigate cross-references. For more\ninformation, see the Google Developers site for the [Code search\ndocumentation](https://developers.google.com/code-search).\n\nOther tools\n-----------\n\n[Android Studio](https://developer.android.com/studio/intro) is the official\nintegrated development environment (IDE) for Android app development.\n\n[Android Debug Bridge (adb)](/docs/setup/build/adb) lets you connect your\ndevelopment workstation directly to your Android-powered device so you can\ninstall packages and evaluate your changes.\n\nFor AOSP development, use [Android Studio for Platform\n(ASfP)](https://developer.android.com/studio/platform)."]]