The Android source is located in a collection of Git repositories hosted by Google. The Git repository includes the entire history of the Android source, including changes to the source and when the changes were made. This page describes how to download the source.
Initialize the Repo client
Set up your client to access the Android source repository:
Create and navigate to a working directory:
$ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY
Initialize your working directory for source control:
$ repo init -b main -u https://android.googlesource.com/platform/manifest
-boption is used to identify the branch you are initializing. If -b isn't provided,
repo initdefaults to the main branch. For a list of branches and tag names, see Source code tags and builds.
-uoption is required and is used to specify a manifest file, which is an XML file specifying where the various Git projects in the Android source are placed within your working directory. In this example, the name of the manifest file isn't specified, so the command uses the default manifest file (
The output should contain the message:
$ repo has been initialized in path_to_working_directory
For information on manifest file format, see repo Manifest Format.
For a list of all Repo commands, see the Repo command reference.
Download the Android source
Run the following command to download the Android source tree to your working directory:
$ repo sync -c -j8
-c argument instructs Repo to fetch the current manifest branch from
the server. The
-j8 command splits the sync across threads for faster
This operation should take a little over an hour.
If you run into any problems during download, refer to Troubleshoot network issues.
Troubleshoot network issues
This section provides several suggestions for fixing network issues that can cause unsuccessful syncs.
Use authentication to avoid quota barriers
To protect the servers against excessive use, each IP address that's used to access source is associated with a quota.
When sharing an IP address with other users, such as when accessing the source repositories from beyond a NAT firewall, quotas can trigger for normal patterns. For example, a quota can trigger when several users sync new clients from the same IP address, within a short period.
To avoid triggering quotas, you can use authenticated access, which uses a separate quota for each user, regardless of the IP address.
To enable authenticated access:
Create a password with the password generator.
Run the following command to convert your client to use automatic authentication (without changing branch):
$ repo init -u https://android.googlesource.com/a/platform/manifest
Note that the
/a/directory prefix triggers automatic authentication.
Configure for proxy use
If you're downloading source from behind a proxy, as is common in some corporate environments, ensure you explicitly specify a proxy for Repo to use by running these commands:
$ export HTTP_PROXY=http://proxy_user_id:proxy_password@proxy_server:proxy_port
$ export HTTPS_PROXY=http://proxy_user_id:proxy_password@proxy_server:proxy_port
Adjust TCP/IP settings to avoid connectivity issues
While it's rare, Linux clients can experience connectivity issues, such as getting stuck in the middle of downloads while receiving objects. To improve this issue, adjust the settings of the TCP/IP stack or use non-parallel connections. You must have root access to modify the TCP setting. To modify the setting, issue the following commands:
$ sudo sysctl -w net.ipv4.tcp_window_scaling=0
$ repo sync -j1
Use a local mirror to avoid network latency
When using several clients, you can create a local mirror of the entire server
content and sync clients from that mirror without accessing the
network. Follow these instructions to create a local mirror in at
~/aosp-mirror/ and sync clients against that mirror:
Create and sync the mirror:
$ mkdir -p /usr/local/aosp/mirror $ cd /usr/local/aosp/mirror $ repo init -u https://android.googlesource.com/mirror/manifest --mirror
These commands create a local mirror in
/user/local/aosp/mirrorand initialize the mirror using the
--mirrorflag with the
To sync clients from the mirror:
$ mkdir -p /usr/local/aosp/main $ cd /usr/local/aosp/main $ repo init -u /usr/local/aosp/mirror/platform/manifest.git $ repo sync
Finally, follow these commands to sync the mirror against the server and sync the client against the mirror:
$ cd /usr/local/aosp/mirror</code> $ repo sync $ cd /usr/local/aosp/main $ repo sync
It's possible to store the mirror on a LAN server and to access it over NFS, SSH, or Git. It's also possible to store it on a removable drive and to pass that drive among users or machines.
Use a partial clone
If you're using Git version 2.19 or later, specify
repo init to overcome any low-latency network issues:
$ repo init -u https://android.googlesource.com/platform/manifest -b main --partial-clone --clone-filter=blob:limit=10M
Instead of initializing Repo to download everything, this command downloads Git objects as they are needed.
Download proprietary binaries
AOSP 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:
- If you're downloading the
mainbranch and building for a Nexus or Pixel device, download the latest binaries from the Binaries preview site.
- If you're downloading and building the
mainbranch and building for your own device, you must provide your device-specific binaries.
- 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 Binaries for Nexus and Pixel devices.
Extract proprietary binaries
Each set of binaries comes as a self-extracting script in a compressed archive. To extract and place these binaries in the correct location of your source tree:
- Extract the archive.
- Run the included self-extracting shell script from the root of your AOSP source tree.
- 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.
(optional) Verify code legitimacy
If you're concerned about the legitimacy of the source code, such as whether it came from Google, you can verify the git tags for the branch. To verify Git tags:
Copy and paste the following key block into a text file, such as
-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v184.108.40.206 (GNU/Linux) mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7 8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq /HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5 jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4 MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9 b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI 2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+ OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM= =Wi5D -----END PGP PUBLIC KEY BLOCK-----
Run the following command to input a public key into your GnuPG key database. The key is used to sign annotated tags that represent releases.
$ gpg --import keyfile.asc
After importing the keys, you can verify any tag by running this command:
$ git tag -v TAG_NAME