[[["容易理解","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-08 (世界標準時間)。"],[],[],null,["# Download the Android source\n\nThe Android source is located in a collection of Git repositories hosted by\nGoogle. The Git repository includes the entire history of the Android source,\nincluding changes to the source and when the changes were made. This page\ndescribes how to download the source.\n| **Note:** All commands on this page are preceded by a dollar sign ($) to differentiate them from output or entries within files. To omit the dollar sign when copying the command, click the **Copy code sample** icon in the top right of each command box.\n| **Note:** To obtain the source code for third-party components where the open source license grants you the right to receive the source, see [Obtain Android source](/docs/setup/download/opensourcerequest).\n\nInitialize the Repo client\n--------------------------\n\nSet up your client to access the Android source repository:\n\n1. Create and navigate to a working directory:\n\n mkdir \u003cvar translate=\"no\"\u003eWORKING_DIRECTORY\u003c/var\u003e\n cd \u003cvar translate=\"no\"\u003eWORKING_DIRECTORY\u003c/var\u003e\n\n | **Note:** You can have more than one version of Android on your development machine as long as they exist in separate directories. Each checkout and build uses at least 300 GB of space.\n2. Initialize your working directory for source control:\n\n repo init --partial-clone --no-use-superproject -b android-latest-release -u https://android.googlesource.com/platform/manifest\n\n The `-b` option is used to identify the branch you're initializing. For a\n list of branches and tag names, see\n [Source code tags and builds](/docs/setup/reference/build-numbers#source-code-tags-and-builds).\n Use tag names or branch names with the `-b` option.\n | **Note:** These instructions assume you're working in the `android-latest-release` branch. If you want to make changes in a different branch, you must initialize your Repo client and download source for that branch.\n\n The `-u` option is required and is used to specify a *manifest* file,\n which is an XML file specifying where the various Git projects\n in the Android source are placed within your working directory.\n In this example, the name of the manifest file isn't specified,\n so the command uses the default manifest file (`default.xml`).\n\n The output should contain the message: \n\n repo has been initialized in \u003cvar translate=\"no\"\u003epath_to_working_directory\u003c/var\u003e\n\nFor information on manifest file format, see\n[repo Manifest Format](https://gerrit.googlesource.com/git-repo/+/main/docs/manifest-format.md).\n\nFor a list of all Repo commands, see the\n[Repo command reference](/docs/setup/reference/repo).\n\nDownload the Android source\n---------------------------\n\nRun the following command to download the Android source tree to your working\ndirectory: \n\n repo sync -c -j8\n\nThe `-c` argument instructs Repo to fetch the current manifest branch from\nthe server. The `-j8` command splits the sync across threads for faster\ncompletion.\n\nThis operation should take a little over an hour.\n\nIf you run into any problems during download, refer to\n[Troubleshoot and fix sync issues](/docs/setup/download/troubleshoot-sync).\n\nDownload proprietary binaries\n-----------------------------\n\nAOSP can run on Cuttlefish emulators directly, but AOSP can't be used on hardware without additional device-specific proprietary libraries. Here's how to obtain those device binaries:\n\n- If you're downloading the `main` branch and building for a Nexus or Pixel device, download the latest binaries from the [Binaries preview site](https://developers.google.com/android/blobs-preview).\n- If you're downloading and building the `main` branch and building for your own device, you must provide your device-specific binaries.\n- If you're downloading and building a tagged, non-main, branch and building for a Nexus or Pixel device, download the device-specific binary from [Driver Binaries for Nexus and Pixel devices](https://developers.google.com/android/drivers).\n\n### Extract proprietary binaries\n\nEach set of binaries comes as a self-extracting script in a compressed\narchive. To extract and place these binaries in the correct location of your\nsource tree:\n\n1. Extract the archive.\n2. Run the included self-extracting shell script from the root of your AOSP source tree.\n3. Agree to the terms of the enclosed license agreement. The binaries and their matching makefiles are installed in the `vendor/` hierarchy of the source tree.\n\n(optional) Verify code legitimacy\n---------------------------------\n\nIf you're concerned about the legitimacy of the source code, such as whether it\ncame from Google, you can verify the Git tags for the branch.\n\nTo verify Git tags:\n\n1. Copy and paste the following key block into a text file, such as\n `keyfile.asc`.\n\n -----BEGIN PGP PUBLIC KEY BLOCK-----\n Version: GnuPG v1.4.2.2 (GNU/Linux)\n\n mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV\n l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y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M\n pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s\n KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb\n N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA\n vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo\n G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ\n hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l\n EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=\n =Wi5D\n -----END PGP PUBLIC KEY BLOCK-----\n\n2. Run the following command to input a public key into your GnuPG key\n database. The key is used to sign annotated tags that represent releases.\n\n gpg --import keyfile.asc\n\n3. After importing the keys, you can verify any tag by running this command:\n\n git tag -v \u003cvar translate=\"no\"\u003eTAG_NAME\u003c/var\u003e"]]