product_name은 빌드하려는 제품의 이름입니다(예: aosp_cf_x86_64_only_phone 또는 aosp_husky). 특정 product_name은 기기의 자체 형식을 따를 수 있지만 Google에서 기기에 사용하는 형식에는 다음 구성요소가 포함됩니다.
aosp는 Android 오픈소스 플랫폼을 나타냅니다.
(선택사항) cf는 타겟이 Cuttlefish 에뮬레이터 내에서 실행되어야 하면 포함됩니다.
아키텍처 및 하드웨어(코드네임)(예: x86_64_only_phone 또는 husky, Pixel 8 Pro의 코드네임) Google 기기의 코드네임 목록은 기기 코드네임을 참고하세요.
release_config는 aosp_current라는 개발 출시 구성과 같은 출시 구성으로 설정됩니다. 출시 구성은 기능 출시 플래그 뒤에 있으며 빌드에 사용 설정 또는 사용 중지된 특정 기능과 코드를 식별합니다. 출시 구성에 관한 자세한 내용은 기능 플래그 출시 값 설정을 참고하세요.
문자열의 build_variant 부분은 다음 표에 나온 세 값 중 하나일 수 있습니다.
build_variant
설명
user
이 빌드 변형은 제한된 보안 액세스 권한을 제공하고 프로덕션에 적합합니다.
userdebug
이 빌드 변형은 기기 개발자가 개발 중인 버전의 성능과 전력을 이해하는 데 도움이 됩니다. userdebug 빌드로 개발할 때는 userdebug 가이드라인을 따르세요.
eng
이 빌드 변형은 빌드 시간이 더 빠르고, 성능과 전력을 신경 쓰지 않는 경우 일상적인 개발에 가장 적합합니다.
인수 없이 lunch를 실행하면 일반적인 타겟 목록이 제공됩니다.
이 페이지의 정보와 기기 코드네임에서 특정 Google 하드웨어를 나타내는 코드네임을 사용하여 타겟 문자열의 요소를 조합하여 자체 타겟 문자열을 만들 수도 있습니다.
현재 타겟 보기
현재 lunch 설정을 보려면 다음을 실행합니다.
$echo"$TARGET_PRODUCT-$TARGET_BUILD_VARIANT"
코드 빌드
다음 명령어를 실행하여 타겟을 빌드하세요. 워크스테이션의 사양에 따라 첫 번째 빌드는 1시간 미만에서 최대 몇 시간까지 걸릴 수 있습니다. 후속 빌드에서는 빌드 시간이 크게 짧아집니다.
m
빌드의 출력이 $OUT_DIR에 표시됩니다. 다른 타겟을 빌드하면 각 타겟 빌드가 $OUT_DIR에 표시됩니다.
m 명령어는 트리 상단에서 빌드되므로 하위 디렉터리 내에서 m을 실행할 수 있습니다. TOP 환경 변수가 설정되어 있으면 m 명령어가 이를 사용합니다. TOP이 설정되어 있지 않으면 m 명령어는 현재 디렉터리에서 트리를 조회하여 트리 상단을 찾으려고 합니다.
m 명령어는 -jN 인수를 사용하여 병렬 작업을 처리할 수 있습니다. -j 인수를 제공하지 않으면 빌드 시스템에서 시스템에 가장 적합한 병렬 작업의 수를 자동으로 선택합니다.
m 명령줄에서 모듈 이름을 나열하여 전체 기기 이미지 대신 특정 모듈을 빌드할 수 있습니다. 또한 m 명령어는 goals라는 의사 타겟을 제공합니다. 예를 들어 m nothing은 아무것도 빌드하지 않지만 빌드 구조를 파싱하고 검증합니다. 유효한 goals 목록을 보려면 m help를 입력하세요.
빌드 오류 문제 해결(8.0 이하)
AOSP 8 이하를 빌드하고 있다면 Java 버전의 문제가 발생할 때 m이 중단될 수 있습니다. 예를 들어 다음 메시지가 표시될 수 있습니다.
이전에 설치된 다른 JDK가 경로에 표시됩니다. 올바른 JDK를 경로의 맨 앞에 추가하거나 문제가 있는 JDK를 삭제합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-29(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-29(UTC)"],[],[],null,["# Build Android\n\nFollow the instructions on this page to build Android.\n\nSet up your build environment\n-----------------------------\n\nFrom within your working directory, source the `envsetup.sh` script to set\nup your build environment: \n\n source build/envsetup.sh\n\nThis script imports several commands that let you work with the Android\nsource code, including the commands used on this page. To view the source of the\nscript, refer to\n[`platform/build/envsetup.sh`](https://android.googlesource.com/platform/build/+/refs/heads/android16-release/envsetup.sh).\nTo view the built-in help, type `hmm`.\n\nChoose a target\n---------------\n\nBefore building Android, you must identify a *target* to build. A target\nreflects the target platform you're building for. To identify your\ntarget to build, use the `lunch` command followed by a string representing\nthe target. For example: \n\n lunch aosp_cf_x86_64_only_phone-aosp_current-userdebug\n\nYou should see is a synopsis of your target and build environment: \n\n ============================================\n PLATFORM_VERSION_CODENAME=Baklava\n PLATFORM_VERSION=Baklava\n TARGET_PRODUCT=aosp_cf_x86_64_only_phone\n TARGET_BUILD_VARIANT=userdebug\n TARGET_ARCH=x86_64\n TARGET_ARCH_VARIANT=silvermont\n HOST_OS=linux\n HOST_OS_EXTRA=Linux-6.10.11-1rodete2-amd64-x86_64-Debian-GNU/Linux-rodete\n HOST_CROSS_OS=windows\n BUILD_ID=BP1A.250305.020\n OUT_DIR=out\n ============================================\n\n| **Note:** You must run `source envsetup.sh` once per shell and before the `lunch` command because `lunch` is defined by `envsetup.sh`.\n\nThe string representing the target has the following format: \n\n lunch \u003cvar translate=\"no\"\u003eproduct_name\u003c/var\u003e-\u003cvar translate=\"no\"\u003erelease_config\u003c/var\u003e-\u003cvar translate=\"no\"\u003ebuild_variant\u003c/var\u003e\n\nThe components of this string are:\n\n- The \u003cvar translate=\"no\"\u003eproduct_name\u003c/var\u003e is the name of the product you want to\n build, such as `aosp_cf_x86_64_only_phone` or `aosp_husky`. Your specific\n \u003cvar translate=\"no\"\u003eproduct_name\u003c/var\u003e can follow your own format for your device,\n but the format that Google uses for its devices has these components:\n\n - `aosp` refers to the Android Open Source Platform.\n - (optional) `cf` is included when the target is intended to be run within the Cuttlefish emulator.\n - Architecture and hardware (codename), such as `x86_64_only_phone` or `husky`, which is the codename for Pixel 8 Pro. For list of codenames for Google devices, see [Device codenames](/docs/setup/reference/build-numbers#build-targets).\n- \u003cvar translate=\"no\"\u003erelease_config\u003c/var\u003e is set to a *release\n configuration* , such as the development release configuration called\n `aosp_current`. A release configuration identifies certain features and\n code that are behind feature launch flags and are either enabled or disabled for\n a build. For more on release configurations, see\n [Set feature flag launch values](/docs/setup/build/feature-flagging/set-values).\n\n- The \u003cvar translate=\"no\"\u003ebuild_variant\u003c/var\u003e portion of the string can be one of\n the three values in the following table:\n\n | \u003cvar translate=\"no\"\u003ebuild_variant\u003c/var\u003e | Description |\n |-----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | `user` | This build variant provides limited security access and is suited for production. |\n | `userdebug` | This build variant helps the device developers understand the performance and power of in-development releases. When developing with a `userdebug` build, follow the [Guidelines for userdebug](/docs/setup/create/new-device#userdebug-guidelines). |\n | `eng` | This build variant has faster build time and is best suited for day-to-day development if you don't care about performance and power. |\n\nIf you run `lunch` without any arguments, a list of common targets is provided.\nYou can also create your own target strings by piecing together the elements of\nthe target string using the information on this page and the codenames\nthat represent specific Google hardware at\n[Device codenames](/docs/setup/reference/build-numbers#build-targets).\n\n### View the current target\n\nTo see the current lunch settings, run: \n\n $ echo \"$TARGET_PRODUCT-$TARGET_BUILD_VARIANT\"\n\nBuild the code\n--------------\n\nRun the following command to build your target. Depending on the specification\nof your workstation, the first build could take less than an hour and up to a\nfew hours. Subsequent builds take significantly less time. \n\n m\n\nThe output of your build appears in \u003cvar translate=\"no\"\u003e$OUT_DIR\u003c/var\u003e. If you\nbuild different targets, each target build appears in\n\u003cvar translate=\"no\"\u003e$OUT_DIR\u003c/var\u003e.\n\nThe `m` command builds from the top of the tree, so you can run `m` from within\nsubdirectories. If you have the `TOP` environment variable set, the `m` command\nuses it. If `TOP` isn't set, the `m` command looks up the tree from the\ncurrent directory, trying to find the top of the tree.\n\nThe `m` command can handle parallel tasks with a `-jN` argument. If you don't\nprovide a `-j` argument, the build system automatically selects a parallel task\ncount that it thinks is optimal for your system.\n\nYou can build specific modules instead of the full device image by listing\nmodule names in your `m` command line. In addition, the `m` command provides\nsome pseudo targets, called *goals* . For example, `m nothing` doesn't build\nanything, but parses and validates the build structure. For a list of valid\ngoals, type `m help`.\n\nTroubleshoot build errors (8.0 or earlier)\n------------------------------------------\n\nIf you're building AOSP 8 or earlier, `m` might abort when it encounters an\nissue with your version of Java. For example, you might get this message: \n\n ************************************************************\n You are attempting to build with the incorrect version\n of java.\n\n Your version is: \u003cvar translate=\"no\"\u003eWRONG_VERSION\u003c/var\u003e.\n The correct version is: \u003cvar translate=\"no\"\u003eRIGHT_VERSION\u003c/var\u003e.\n\n Please follow the machine setup instructions at\n https://source.android.com/source/initializing.html\n ************************************************************\n\nHere are the likely causes and solutions:\n\n- You failed to install the correct JDK as specified in the JDK sections of [Set Up for AOSP development (2.3 - 8.0)](/docs/setup/start/older-versions).\n- There's another previously installed JDK appearing in your path. Prepend the correct JDK to the beginning of your path or remove the problematic JDK."]]