AOSP(Android Open Source Project)는 많은 git project들로 이루어져있습니다. Full Build를 하려면 우리는 각각의 git project를 다운받아서 폴더별로 정리를 한 뒤에 Build를 해야 하는데요. 매우 귀찮은 작업이기 때문에, Google에서는 REPO라는 툴을 만들어 쉽게 다운로드 및 업데이트할 수 있도록 관리하고 있습니다.
따라서, 먼저 repo라는 툴을 설치하고 repo를 통해 AOSP 코드들을 다운로드하시면 됩니다.
AOSP 다운로드에 대한 자세한 내용은 AOSP Download Guide 에 소개되어있습니다.
1. REPO 설치
Repo는 script로 구현된 Tool입니다. 다운만 받아주면 되요. 먼저 ~/bin 폴더를 생성하고 PATH에 등록해주세요
$ mkdir ~/bin
$ PATH=~/bin:$PATHcurl 명령어로 repo tool을 ~/bin폴더에 다운받습니다. 그리고 repo에 실행권한을 주었습니다.
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo2. Android 12 소스코드 다운로드
Repo를 이용하여 안드로이드 오픈소스를 받기 전에 폴더를 먼저 생성합니다. 적당한 곳에 생성하시고 생성한 폴더 안으로 이동해주세요.
$ mkdir android12
$ cd android12그리고 Repo는 git을 이용하기 때문에 git을 설치하셔야 합니다. git을 설치하셨으면 기본적인 설정인 user name과 user email을 등록하셔야 합니다. 자신의 이름과 email을 입력해주세요.
$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"이제 준비는 모두 되었고, Repo로 AOSP의 어떤 version을 받을지 설정을 해야 합니다.
아래 명령어에서 옵션 -b android-12.0.0_r27는 android-12.0.0_r27 브랜치 소스를 받겠다는 의미입니다.
이를 입력하지 않으면 최신 소스를 받는다고합니다.
AOSP의 모든 브랜치 정보들은 Source Code Tags and Builds에서 확인할 수 있습니다.
android-12.0.0_r27보다 더 최신 브랜치가 있다면 그것을 다운받으시면 됩니다.
아래와 같이 repo init 명령어로 Repository 정보를 다운로드 받습니다.
$ repo init -u https://android.googlesource.com/platform/manifest -b android-12.0.0_r27
Downloading Repo source from https://gerrit.googlesource.com/git-repo
repo: Updating release signing keys to keyset ver 2.3
... A new version of repo (2.17) is available.
... You should upgrade soon:
cp /home/js/Desktop/android12/.repo/repo/repo /home/js/.bin/repo
Downloading manifest from https://android.googlesource.com/platform/manifest
remote: Sending approximately 125.99 MiB ...
remote: Counting objects: 1395, done
remote: Finding sources: 100% (55/55)
remote: Total 94791 (delta 30041), reused 94778 (delta 30041)
Receiving objects: 100% (94791/94791), 126.04 MiB | 10.82 MiB/s, done.
Resolving deltas: 100% (30041/30041), done.
Your identity is: farfs <farfs.dev@gmail.com>
If you want to change this, please re-run 'repo init' with --config-name
repo has been initialized in /home/js/Desktop/android12
repo init으로 repo 정보를 받으셨으면 repo sync로 AOSP의 git project들의 모든 소스들을 다운로드합니다. 파일 크기가 매우 크기 때문에 시간이 조금 걸립니다.
$ repo sync
... A new version of repo (2.17) is available.
... You should upgrade soon:
Receiving objects: 100% (6238/6238), 5.32 MiB | 25.67 MiB/s, done.
Resolving deltas: 100% (1584/1584), done.
Receiving objects: 100% (13918/13918), 7.89 MiB | 37.74 MiB/s, done.
Resolving deltas: 100% (4645/4645), done.
Receiving objects: 100% (1493/1493), 1.10 MiB | 43.47 MiB/s, done.
.....3. AOSP 다운로드 확인
repo sync가 완료되면 모든 코드들이 다운로드 된 것입니다.
다운로드가 완료되면 아래처럼 파일을 확인할 수 있습니다.
$ ls
Android.bp bionic bootstrap.bash compatibility dalvik development docs frameworks kernel libnativehelper packages platform_testing sdk test tools
art bootable build cts developers device external hardware libcore Makefile pdk prebuilts system toolchain4. AOSP 빌드
먼저 다운로드 받은 프로젝트에서 다음 명령어로 빌드 관련 의존성을 설정합니다.
$ source build/envsetup.shsource 명령어를 입력하실 때는, 다운로드 받은 AOSP 폴더의 최상위 폴더에서 명령어를 입력하셔야 합니다. 최상위 폴더에 바로 아래에
build/폴더가 있습니다.
그리고, 다음 명령어로 어떤 타입의 디바이스 또는 아키텍처를 빌드할지 선택합니다.
$ lunch
You\'re building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_mips-eng
4. aosp_mips64-eng
5. aosp_x86-eng
6. aosp_x86_64-eng
....
Which would you like? [aosp_arm-eng] 6디바이스 및 아키텍처까지 설정을 모두 마치셨다면, 다음 명령어로 전체 빌드를 할 수 있습니다. -jN은 빌드할 때 사용할 쓰레드 개수를 설정하는 옵션입니다.
$ m -j85. 에뮬레이터로 안드로이드 실행
빌드가 완료되면 이미지들이 생성됩니다. 에뮬레이터와 컴파일된 이미지로 안드로이드를 실행할 수 있습니다.
다음 명령어를 입력하시면 컴파일된 안드로이드 이미지가 에뮬레이터에서 실행됩니다.
$ emulator위에서 환경설정할 때 QEMU도 설정되었기 때문에 간단한 명령어로 실행이 가능한 것입니다. 개별적으로 QEMU를 설치했다면 실행 명령어에 이미지 위치를 옵션으로 주어 실행할 수도 있습니다.
참고
Related Posts
- Android 14 - 사진/동영상 파일, 일부 접근 권한 소개
- Android - adb push, pull로 파일 복사, 다운로드
- Android 14 - 암시적 인텐트 변경사항 및 문제 해결
- Jetpack Compose - Row와 Column
- Android 13, AOSP 오픈소스 다운로드 및 빌드
- Android 13 - 세분화된 미디어 파일 권한
- Android 13에서 Notification 권한 요청, 알림 띄우기
- Android 13에서 'Access blocked: ComponentInfo' 에러 해결
- 에러 해결: android gradle plugin requires java 11 to run. you are currently using java 1.8.
- 안드로이드 - 코루틴과 Retrofit으로 비동기 통신 예제
- 안드로이드 - 코루틴으로 URL 이미지 불러오기
- Android - 진동, Vibrator, VibrationEffect 예제
- Some problems were found with the configuration of task 에러 수정
- Query method parameters should either be a type that can be converted into a database column or a List
- 우분투에서 Android 12 오픈소스 다운로드 및 빌드
- Android - ViewModel을 생성하는 방법
- Android - Transformations.map(), switchMap() 차이점
- Android - Transformations.distinctUntilChanged() 소개
- Android - TabLayout 구현 방법 (+ ViewPager2)
- Android - 휴대폰 전화번호 가져오는 방법
- Android 12 - Splash Screens 알아보기
- Android 12 - Incremental Install (Play as you Download) 소개
- Android - adb 명령어로 bugreport 로그 파일 추출
- Android - adb 명령어로 App 데이터 삭제
- Android - adb 명령어로 앱 비활성화, 활성화
- Android - adb 명령어로 특정 패키지의 PID 찾기
- Android - adb 명령어로 퍼미션 Grant 또는 Revoke
- Android - adb 명령어로 apk 설치, 삭제
- Android - adb 명령어로 특정 패키지의 프로세스 종료
- Android - adb 명령어로 screen capture 저장
- Android - adb 명령어로 System 앱 삭제, 설치
- Android - adb 명령어로 settings value 확인, 변경
- Android 12 - IntentFilter의 exported 명시적 선언
- Android - adb 명령어로 공장초기화(Factory reset)
- Android - adb logcat 명령어로 로그 출력