Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trước khi tải xuống và tạo nhánh phát hành mới nhất của Android (android16-release) của nguồn Android, hãy đảm bảo rằng phần cứng của bạn đáp ứng các yêu cầu cần thiết và phần mềm cần thiết được cài đặt đúng cách. Bạn cũng cần nắm rõ các thuật ngữ sau:
Git
Git là một hệ thống quản lý phiên bản phân phối nguồn mở và miễn phí.
Android sử dụng Git cho các thao tác cục bộ như phân nhánh, xác nhận, khác biệt và chỉnh sửa. Để được trợ giúp về cách tìm hiểu Git, hãy tham khảo tài liệu về Git.
Kho lưu trữ
Repo là một trình bao bọc Python xung quanh Git giúp đơn giản hoá việc thực hiện các thao tác phức tạp trên nhiều kho lưu trữ Git. Repo không thay thế Git cho tất cả các thao tác kiểm soát phiên bản, mà chỉ giúp bạn dễ dàng thực hiện các thao tác phức tạp trong Git. Kho lưu trữ sử dụng tệp kê khai để tổng hợp các dự án Git vào siêu dự án Android.
Tệp kê khai
Tệp kê khai là tệp XML chỉ định vị trí đặt các dự án Git khác nhau trong nguồn Android trong cây nguồn AOSP.
Đáp ứng các yêu cầu về phần cứng
Máy trạm phát triển của bạn phải đáp ứng hoặc vượt quá các yêu cầu về phần cứng sau:
Hệ thống x86 64 bit.
Ít nhất 400 GB dung lượng ổ đĩa trống để kiểm tra và tạo mã
(250 GB để kiểm tra + 150 GB để tạo).
RAM tối thiểu 64 GB. Google sử dụng máy 72 nhân với 64 GB
RAM để xây dựng Android. Với cấu hình phần cứng này, bạn sẽ mất khoảng 40 phút để tạo một bản dựng Android đầy đủ và chỉ mất vài phút để tạo một bản dựng Android tăng dần. Ngược lại, một bản dựng đầy đủ trên máy 6 nhân có 64 GB RAM sẽ mất khoảng 6 giờ.
Đáp ứng các yêu cầu về hệ điều hành
Máy trạm phát triển của bạn phải chạy bất kỳ bản phân phối Linux 64 bit nào có Thư viện GNU C (glibc) 2.17 trở lên.
Cài đặt các gói bắt buộc
Để tạo Android 11 trở lên, bạn phải sử dụng Ubuntu 18.04 trở lên. Để cài đặt các gói bắt buộc cho Ubuntu 18.04 trở lên, hãy chạy lệnh sau:
Trong số các gói đã cài đặt, lệnh này sẽ cài đặt Git, dùng để tải nguồn AOSP xuống.
Cài đặt phần mềm bắt buộc
Trước khi có thể làm việc với AOSP, bạn phải cài đặt OpenJDK, Make, Python 3 và Repo. Nhánh phát hành mới nhất của Android đi kèm với các phiên bản tạo sẵn của OpenJDK, Make và Python 3, vì vậy, bạn không cần thực hiện các bước cài đặt bổ sung. Phần sau đây giải thích cách cài đặt Repo.
Cài đặt Repo
Làm theo các bước sau để cài đặt Repo:
Tải thông tin gói hiện tại xuống:
sudoapt-getupdate
Chạy lệnh sau để cài đặt trình chạy Repo:
sudoapt-getinstallrepo
Trình chạy Repo cung cấp một tập lệnh Python khởi chạy quy trình thanh toán và tải công cụ Repo đầy đủ xuống.
Nếu thành công, hãy chuyển sang bước 4.
(không bắt buộc) Cài đặt Repo theo cách thủ công bằng loạt lệnh sau:
Ba lệnh đầu tiên thiết lập một tệp tạm thời, tải Repo xuống tệp và xác minh rằng khoá được cung cấp khớp với khoá bắt buộc. Nếu các lệnh này thành công, lệnh cuối cùng sẽ cài đặt trình chạy Repo.
Xác minh phiên bản trình chạy Repo:
repoversion
Kết quả sẽ cho biết phiên bản 2.4 trở lên, ví dụ:
repo launcher version 2.45
Đặt thư mục đầu ra thay thế
Theo mặc định, kết quả của mỗi bản dựng được lưu trữ trong thư mục con out/ của cây nguồn trùng khớp. Bạn có thể ghi đè thư mục này bằng cách xuất biến môi trường OUT_DIR. Ví dụ: nếu muốn lưu trữ đầu ra trên một ổ khác, bạn có thể trỏ OUT_DIR đến ổ đó:
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Set up for AOSP development (9.0 or later)\n\nBefore you download and build the Android latest release branch\n(android16-release) of the Android source, ensure\nthat your hardware meets the necessary requirements and that required software\nis properly installed. You should also be familiar with the following terms:\n\n*Git*\n: Git is a free and open source distributed version control system.\n Android uses Git for local operations such as branching, commits, diffs,\n and edits. For help learning Git, refer to the [Git documentation](https://git-scm.com/doc).\n\n*Repo*\n: Repo is a Python wrapper around Git that simplifies performing\n complex operations across multiple Git repositories. Repo doesn't replace Git\n for all version control operations, it only makes complex Git operations easier\n to accomplish. Repo uses manifest files to aggregate Git projects into the\n Android superproject.\n\n*Manifest file*\n: A manifest file is an XML file specifying where the various Git projects in\n the Android source are placed within an AOSP source tree.\n| **Note:** All commands in this documentation are preceded by a dollar sign ($) to differentiate them from output or entries within files. To copy a command to the clipboard, click the **Copy code sample** icon in the top right of each command box.\n| **Note:** If you want to build Android 2.3 - 8.0, refer to [Set up for AOSP development (2.3 - 8.0)](/docs/setup/start/older-versions).\n\nMeet hardware requirements\n--------------------------\n\nYour development workstation should meet or exceed these hardware\nrequirements:\n\n- A 64-bit x86 system.\n\n | **Note:** You can compile AOSP versions previous to 2.3.x on 32-bit systems.\n- At least 400 GB of free disk space to check out and build the code\n (250 GB to check out + 150 GB to build).\n\n | **Note:** If you're checking out a mirror, you need more space because the full Android Open Source Project (AOSP) mirrors contain all Git repositories that have ever been used.\n- A minimum of 64 GB of RAM. Google uses 72-core machines with 64 GB\n of RAM to build Android. With this hardware configuration, it takes\n approximately 40 minutes for a full build of Android and only a few minutes for incremental build of Android. By contrast, it takes approximately 6 hours for a\n full build with a 6-core machine with 64 GB of RAM.\n\nMeet operating system requirements\n----------------------------------\n\nYour development workstation must run any 64-bit Linux distribution with GNU C\nLibrary (glibc) 2.17 or later.\n| **Warning:** Android OS development on macOS isn't supported as of June 22, 2021 (Android 11). For information on configuring your development workstation for macOS, refer to [Set Up for AOSP development (2.3 - 8.0)](/docs/setup/start/older-versions).\n\nInstall required packages\n-------------------------\n\nTo build Android 11 or higher, you must use Ubuntu 18.04 or later. To install\nrequired packages for Ubuntu 18.04 or later, run the following command: \n\n sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig\n\nAmong the packages installed, this command installs Git, which is used to\ndownload the AOSP source.\n| **Note:** This command works for Ubuntu 18.04 or later. For package installation for earlier versions of Ubuntu, see [Setup for Android development (AOSP 2.3 - 8)](/docs/setup/start/older-versions).\n\nInstall required software\n-------------------------\n\nBefore you can work with AOSP, you must have installations of OpenJDK, Make,\nPython 3, and Repo. The latest release branch of Android comes with prebuilt\nversions of OpenJDK, Make, and Python 3, so additional installation steps aren't\nrequired. The following section explains how to install Repo.\n\n### Install Repo\n\nFollow these steps to install Repo:\n\n1. Download the current package information:\n\n sudo apt-get update\n\n2. Run the following command to install the Repo launcher:\n\n sudo apt-get install repo\n\n The Repo launcher provides a Python script that initializes a checkout\n and downloads the full Repo tool.\n\n If successful, skip to step 4.\n3. (optional) Manually install Repo using the following series of commands:\n\n export REPO=$(mktemp /tmp/repo.XXXXXXXXX)\n curl -o ${REPO} https://storage.googleapis.com/git-repo-downloads/repo\n gpg --recv-keys 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65\n curl -s https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - ${REPO} && install -m 755 ${REPO} ~/bin/repo\n\n The first three commands set up a temp file, download Repo to the file, and\n verify that the key provided matches the required key. If these commands are\n successful, the final command installs the Repo launcher.\n4. Verify the Repo launcher version:\n\n repo version\n\n The output should indicate a version of 2.4 or higher, for example:\n\n `repo launcher version 2.45`\n\nSet an alternative output directory\n-----------------------------------\n\nBy default, the output of each build is stored in the `out/` subdirectory of\nthe matching source tree. You can override this directory by exporting the\n`OUT_DIR` environment variable. For example, if you want to store your output\non a different drive, you can point `OUT_DIR` to that drive: \n\n export OUT_DIR=\u003cvar translate=\"no\"\u003emy_other_drive\u003c/var\u003e\n\nWhat's next?\n------------\n\n- To download the source code, continue to [Download the Android source](/docs/setup/download).\n- For help learning Git, see the [Git documentation](https://git-scm.com/doc).\n- For additional Repo documentation, see the [Repo README](https://gerrit.googlesource.com/git-repo/+/refs/heads/main/README.md).\n- For a list of all Repo commands, refer to the [Repo command reference](/docs/setup/reference/repo)."]]