Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release, bukan aosp-main, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Kode sumber Android berada di kumpulan repositori Git yang dihosting oleh
Google. Repositori Git mencakup seluruh histori sumber Android, termasuk perubahan pada sumber dan kapan perubahan tersebut dilakukan. Halaman ini menjelaskan cara mendownload sumber.
Lakukan inisialisasi klien Repo
Siapkan klien Anda untuk mengakses repositori sumber Android:
Buat dan buka direktori kerja:
mkdirWORKING_DIRECTORYcdWORKING_DIRECTORY
Lakukan inisialisasi direktori kerja Anda untuk kontrol sumber:
Opsi -b digunakan untuk mengidentifikasi cabang yang Anda inisialisasi. Untuk
daftar nama cabang dan tag, lihat
Tag dan build kode sumber.
Gunakan nama tag atau nama cabang dengan opsi -b.
Opsi -u diperlukan dan digunakan untuk menentukan file manifest, yang merupakan file XML yang menentukan lokasi berbagai project Git dalam sumber Android di direktori kerja Anda.
Dalam contoh ini, nama file manifes tidak ditentukan,
sehingga perintah menggunakan file manifes default (default.xml).
Output harus berisi pesan:
repohasbeeninitializedinpath_to_working_directory
Untuk mengetahui informasi tentang format file manifes, lihat
Format Manifes repo.
Jalankan perintah berikut untuk mendownload hierarki sumber Android ke direktori kerja Anda:
reposync-c-j8
Argumen -c menginstruksikan Repo untuk mengambil cabang manifes saat ini dari
server. Perintah -j8 membagi sinkronisasi di seluruh thread agar penyelesaiannya lebih cepat.
Operasi ini akan memerlukan waktu lebih dari satu jam.
AOSP dapat berjalan langsung di emulator Cuttlefish, tetapi AOSP tidak dapat digunakan di hardware tanpa library eksklusif tambahan khusus perangkat. Berikut cara mendapatkan biner perangkat tersebut:
Jika Anda mendownload cabang main dan membuat build untuk perangkat Nexus atau Pixel, download biner terbaru dari situs pratinjau Biner.
Jika Anda mendownload dan membuat cabang main serta membuat untuk perangkat Anda sendiri, Anda harus menyediakan biner khusus perangkat Anda.
Jika Anda mendownload dan membuat cabang yang diberi tag, non-utama, dan membuat
untuk perangkat Nexus atau Pixel, download biner khusus perangkat dari
Biner Driver untuk perangkat Nexus dan Pixel.
Mengekstrak biner eksklusif
Setiap set biner hadir sebagai skrip yang dapat diekstrak sendiri dalam arsip yang dikompresi. Untuk mengekstrak dan menempatkan biner ini di lokasi yang benar pada struktur direktori sumber Anda:
Ekstrak arsip.
Jalankan skrip shell yang dapat mengekstrak sendiri dari root hierarki sumber AOSP Anda.
Setujui persyaratan perjanjian lisensi yang terlampir. Biner dan makefile yang cocok diinstal dalam hierarki vendor/ pohon sumber.
(opsional) Verifikasi keabsahan kode
Jika Anda khawatir tentang keabsahan kode sumber, seperti apakah kode tersebut berasal dari Google, Anda dapat memverifikasi tag git untuk cabang. Untuk memverifikasi tag Git:
Salin dan tempel blok kunci berikut ke dalam file teks, seperti
keyfile.asc.
-----BEGIN PGP PUBLIC KEY BLOCK-----Version:GnuPG v1.4.2.2 (GNU/Linux)mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSVlFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw78tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMDu4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0ZwNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9b/aF/ygcR8mh5hgUfpF9I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-----
Jalankan perintah berikut untuk memasukkan kunci publik ke dalam database kunci GnuPG Anda. Kunci ini digunakan untuk menandatangani tag beranotasi yang merepresentasikan rilis.
gpg--importkeyfile.asc
Setelah mengimpor kunci, Anda dapat memverifikasi tag apa pun dengan menjalankan perintah ini:
gittag-vTAG_NAME
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-08 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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+uUGapw4tWCp4o0dpIvDPBEa9\n b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv\n aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k\n cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX\n gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI\n 2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl\n QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up\n hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk\n C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX\n LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+\n OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/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"]]