Download the Android source

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:

  1. Create and navigate to a working directory:

    mkdir WORKING_DIRECTORY
    cd WORKING_DIRECTORY
    
  2. Initialize your working directory for source control:

    repo init --partial-clone -b main -u https://android.googlesource.com/platform/manifest
    

    The -b option is used to identify the branch you are initializing. If -b isn't provided, repo init defaults to the main branch. For a list of branches and tag names, see Source code tags and builds.

    The -u option 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 (default.xml).

    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

The -c argument instructs Repo to fetch the current manifest branch from the server. The -j8 command splits the sync across threads for faster completion.

This operation should take a little over an hour.

If you run into any problems during download, refer to Troubleshoot and fix sync issues.

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 main branch and building for a Nexus or Pixel device, download the latest binaries from the Binaries preview site.
  • If you're downloading and building the main branch 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:

  1. Extract the archive.
  2. Run the included self-extracting shell script from the root of your AOSP source tree.
  3. 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:

  1. Copy and paste the following key block into a text file, such as keyfile.asc.

    -----BEGIN PGP PUBLIC KEY BLOCK-----
    Version: GnuPG v1.4.2.2 (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-----
    
  2. 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
    
  3. After importing the keys, you can verify any tag by running this command:

    $ git tag -v TAG_NAME