Ab dem 27. März 2025 empfehlen wir, android-latest-release anstelle von aosp-main zu verwenden, um AOSP zu erstellen und Beiträge dazu zu leisten. Weitere Informationen finden Sie unter Änderungen am AOSP.
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Der Android-Quellcode befindet sich in einer Sammlung von Git-Repositories, die von Google gehostet werden. Das Git-Repository enthält den gesamten Verlauf des Android-Quellcodes, einschließlich Änderungen am Quellcode und des Zeitpunkts, zu dem die Änderungen vorgenommen wurden. Auf dieser Seite wird beschrieben, wie Sie den Quellcode herunterladen.
Repo-Client initialisieren
Richten Sie Ihren Client für den Zugriff auf das Android-Quellcode-Repository ein:
Erstellen Sie ein Arbeitsverzeichnis und wechseln Sie zu diesem Verzeichnis:
mkdirWORKING_DIRECTORYcdWORKING_DIRECTORY
Initialisieren Sie Ihr Arbeitsverzeichnis für die Quellcodeverwaltung:
Mit der Option -b wird der Zweig angegeben, den Sie initialisieren. Eine Liste der Branches und Tag-Namen finden Sie unter Quellcode-Tags und Builds.
Verwenden Sie Tag- oder Branch-Namen mit der Option -b.
Die Option -u ist erforderlich und wird verwendet, um eine Manifestdatei anzugeben. Das ist eine XML-Datei, in der angegeben wird, wo die verschiedenen Git-Projekte im Android-Quellcode in Ihrem Arbeitsverzeichnis platziert werden.
In diesem Beispiel wird der Name der Manifestdatei nicht angegeben, sodass der Befehl die Standardmanifestdatei (default.xml) verwendet.
Die Ausgabe sollte die folgende Meldung enthalten:
Führen Sie den folgenden Befehl aus, um den Android-Quellcodebaum in Ihr Arbeitsverzeichnis herunterzuladen:
reposync-c-j8
Das Argument -c weist Repo an, den aktuellen Manifest-Branch vom Server abzurufen. Der Befehl -j8 teilt die Synchronisierung auf Threads auf, damit sie schneller abgeschlossen wird.
Dieser Vorgang sollte etwas mehr als eine Stunde dauern.
AOSP kann direkt auf Cuttlefish-Emulatoren ausgeführt werden, aber nicht auf Hardware ohne zusätzliche gerätespezifische proprietäre Bibliotheken. So erhalten Sie die Geräte-Binärdateien:
Wenn Sie den main-Branch herunterladen und für ein Nexus- oder Pixel-Gerät erstellen, laden Sie die neuesten Binärdateien von der Binaries Preview-Website herunter.
Wenn Sie den main-Branch herunterladen und erstellen und für Ihr eigenes Gerät erstellen, müssen Sie Ihre gerätespezifischen Binärdateien bereitstellen.
Wenn Sie einen getaggten, nicht primären Branch herunterladen und erstellen und für ein Nexus- oder Pixel-Gerät erstellen, laden Sie die gerätespezifische Binärdatei von Treiber-Binärdateien für Nexus- und Pixel-Geräte herunter.
Proprietäre Binärdateien extrahieren
Jeder Satz von Binärdateien wird als selbstentpackendes Skript in einem komprimierten Archiv bereitgestellt. So extrahieren Sie diese Binärdateien und platzieren sie an der richtigen Stelle in Ihrem Quellbaum:
Extrahieren Sie das Archiv.
Führen Sie das enthaltene selbstentpackende Shell-Skript im Stammverzeichnis Ihres AOSP-Quellbaums aus.
Stimmen Sie den Bedingungen der beiliegenden Lizenzvereinbarung zu. Die Binärdateien und die entsprechenden Makefiles werden in der vendor/-Hierarchie des Quellbaums installiert.
(Optional) Code auf Rechtmäßigkeit prüfen
Wenn Sie Bedenken hinsichtlich der Rechtmäßigkeit des Quellcodes haben, z. B. ob er von Google stammt, können Sie die Git-Tags für den Branch prüfen. So prüfen Sie Git-Tags:
Kopieren Sie den folgenden Schlüsselblock und fügen Sie ihn in eine Textdatei wie keyfile.asc ein.
-----BEGIN PGP PUBLIC KEY BLOCK-----Version:GnuPG v1.4.2.2 (GNU/Linux)mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSVlFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw78tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMDu4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0ZwNj96SA8BL+a1O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KgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwoG1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQhN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0lEXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM==Wi5D-----END PGP PUBLIC KEY BLOCK-----
Führen Sie den folgenden Befehl aus, um einen öffentlichen Schlüssel in Ihre GnuPG-Schlüsseldatenbank einzugeben. Der Schlüssel wird zum Signieren von annotierten Tags verwendet, die Releases darstellen.
gpg--importkeyfile.asc
Nach dem Importieren der Schlüssel können Sie ein beliebiges Tag mit diesem Befehl überprüfen:
gittag-vTAG_NAME
Alle Inhalte und Codebeispiele auf dieser Seite unterliegen den Lizenzen wie im Abschnitt Inhaltslizenz beschrieben. Java und OpenJDK sind Marken oder eingetragene Marken von Oracle und/oder seinen Tochtergesellschaften.
Zuletzt aktualisiert: 2025-08-08 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-08 (UTC)."],[],[],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 lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7\n 8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD\n u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z\n wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq\n /HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5\n jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4\n MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA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mR0l\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"]]