- 전체
- android studio
- Android SDK
- Android NDK
- Android ADK
- Android Etc. Lib.
- Android dalvik VM
- Android 보안
- PhoneGap
- AOSP 개발
- MIT App Inventor 2
- kivy (python)
- ionic framework
- Kotlin (코틀린)
- React Native
AOSP 개발 AOSP 개발환경을 vagrant를 활용해 좀 더 손쉽게 꾸려보자
2014.09.28 21:10
AOSP 개발환경을 vagrant를 활용해 좀 더 손쉽게 꾸려보자
[출처] http://bl.ocks.org/chitacan/932aa8c9946411cb81d3
AOSP_vagrant.md
# 개발환경 꾸리기
[AOSP(Android Open Source Project)](https://android.googlesource.com/) 개발환경을 [vagrant](http://www.vagrantup.com/) 를 활용해 좀 더 편하게 꾸려보자
## 진짜?
`vagrant`를 활용하면 다음과 같은 명령어 만으로도 AOSP 빌드환경을 갖춘 가상머신을 생성하고 빌드를 진행할 수 있습니다.
$ wget http://goo.gl/OnTHI4 -O Vagrantfile
$ vagrant up
$ vagrant ssh
vagrant$ cd workspace/android-4.4_r1/
vagrant$ repo sync
vagrant$ . build/envsetup
vagrant$ lunch aosp_hammerhead-eng
vagrant$ make -j8 updatepackage
## 아, 필요한 것들이 있습니다.
* [Virtualbox](https://www.virtualbox.org/wiki/Downloads) 가 설치되어 있어야합니다.
* [Vagrant](http://www.vagrantup.com/downloads.html) 도 설치되어 있어야 합니다.
* 충분한 시간
* vagrant box 다운로드(dropbox 에 호스팅된 1.3GB 정도의 파일을 다운로드 받아야 합니다.)
* AOSP 다운로드(아시다시피 상당한 시간이 필요합니다.)
## 위에서 나온 명령어를 하나씩 살펴봅시다.
### vagrant 설치
[vagrant](http://www.vagrantup.com/) 는 가상머신의 설정과정과 소프트웨어 설치과정을 자동화 할 수 있는 도구입니다. `windows`, `OS X`, `Linux` 를 모두 지원합니다.
[vagrant](http://www.vagrantup.com/) 를 활용해 가상머신을 설치하기 위해서는 가상머신의 정보를 담은 `Vagrantfile` 과 운영체제의 정보를 담은 `*.box` 파일이 필요합니다.
### `wget http://goo.gl/OnTHI4 -O Vagrantfile`
위 명령어는 [http://goo.gl/OnTHI4](http://goo.gl/OnTHI4) 의 파일을 `Vagrantfile`로 저장합니다.
[http://goo.gl/OnTHI4](http://goo.gl/OnTHI4) 는 사실 [https://gist.github.com/chitacan/f8f8c2702c367df515de](https://gist.github.com/chitacan/f8f8c2702c367df515de) 의 Raw 링크 입니다.
이 `Vagrantfile` 에는 가상머신을 실행하는데 사용할 [box의 이름](https://gist.github.com/chitacan/f8f8c2702c367df515de#file-vagrantfile-L16) 과 [box가 호스팅되어 있는 url](https://gist.github.com/chitacan/f8f8c2702c367df515de#file-vagrantfile-L20) 이 선언되어 있습니다. 이는 다음에 살펴볼 `vagrant up` 명령어를 실행할 때 사용됩니다.
#### robust-android-v1.box
[Vagrantfile](https://gist.github.com/chitacan/f8f8c2702c367df515de) 에 선언된 `robust-android-v1` box에는 Ubuntu 12.04 server 64 bit 에 AOSP 빌드환경과 여러 도구들을 미리 설치해 두었습니다.
* JDK, git, python, repo 등등
* 그 외에도 tmux, node.js, vim 플러그인(Vundle)
* `workspace/android-4.4_r1` 디렉토리에 `android-4.4_r1` 브랜치를 checkout 할 수 있도록 설정해 놓았습니다.
#### 가상머신에서 사용할 리소스 설정
`Vagrantfile` 의 [이 부분](https://gist.github.com/chitacan/f8f8c2702c367df515de#file-vagrantfile-L54-L56) 을 수정해 가상머신에서 사용할 하드웨어 리소스를 설정할 수 있습니다. 예를 들어 가상머신에 12GB 의 메모리, 4개의 CPU 를 할당하고 각 CPU의 80%만 사용하고자 한다면 아래와 같이 수정하면 되겠습니다.
```ruby
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", (1024*12).to_s]
vb.customize ["modifyvm", :id, "--cpus", "4"]
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "80"]
end
```
### `vagrant up`
`Vagrantfile` 이 있는 디렉토리에서 `vagrant up` 명령을 실행하면, `Vagrantfile` 의 내용을 읽어 가상머신을 실행합니다.
`Vagrantfile`의 `config.vm.box` 이름에 해당하는 `box`가 없는 경우, 자동으로 `config.vm.box_url`에서 `box`를 가져와 설치해 줍니다.
### `vagrant ssh`
vagrant로 실행된 가상머신에 `ssh` 로 접속할 수 있습니다.
> vagrant의 다른 명령어들은 [http://docs.vagrantup.com/v2/cli/index.html](http://docs.vagrantup.com/v2/cli/index.html) 에서 확인할 수 있습니다.
### `cd workspace/android-4.4_r1/`, `repo sync`
`robust-android-v1` box에는 `android-4.4_r1` 를 바로 다운로드 받을 수 있도록 세팅해 놓았기 때문에 다른 환경설정이 필요없이 바로 `repo sync` 명렁어로 `android-4.4_r1` 브랜치에 해당하는 소스를 다운로드 받을 수 있습니다.
### `. build/envsetup`
`build/envsetup` 스크립트를 실행하면 AOSP 를 개발할 때 유용하게 사용할 수 있는 함수들이 설정되는데 이 함수들에 대한 설명은 `hmm` 명령으로 살펴볼 수 있습니다.
vagrant$ . build/envsetup
vagrant$ hmm
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- lunch: lunch <product_name>-<build_variant>
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5] [eng|userdebug|user]
- croot: Changes directory to the top of the tree.
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory, but not their dependencies.
- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
- mma: Builds all of the modules in the current directory, and their dependencies.
- mmma: Builds all of the modules in the supplied directories, and their dependencies.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file.
Look at the source to view more functions. The complete list is:
...
### `lunch aosp_hammerhead-eng`
넥서스 5(`hammerhead`)를 타겟으로 설정합니다.
### `make -j8 updatepackage`
`robust-android-v1` box에는 빌드에 필요한 것들이 모두 설치되어 있기 때문에 별다른 설정없이 바로 빌드가 가능합니다.
`updatepackage` 타겟은 AOSP 빌드후 단말 업로드에 필요한 파일들(`boot.img`, `ramdisk.img`, `system.img`, `userdata.img`, `recovery.img` 등) 을 압축해 줍니다.
vagrant로 설정된 가상머신의 `/vagrant` 디렉토리는 호스트 머신의 `Vagrantfile`이 위치한 디렉토리가 마운트 됩니다. 이를 잘 활용하면 vagrant로 시작된 가상머신과 호스트 머신간에 파일을 손쉽게 교환할 수 있습니다.
#### 단말에 업로드
vagrant$ cp out/target/product/hammerhead/full_hammerhead-img-eng.vagrant.zip /vagrant/
vagrant$ exit
$ adb reboot bootloader
$ fastboot -w update full_hammerhead-img-eng.vagrant.zip본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 8 |
Ionic Framework로 만화 사이트 어플 만들기 #3
| 졸리운_곰 | 2016.07.31 | 273 |
| 7 |
Ionic Framework로 만화 사이트 어플 만들기 #2
| 졸리운_곰 | 2016.07.31 | 570 |
| 6 |
Ionic Framework로 만화 사이트 어플 만들기 #1
| 졸리운_곰 | 2016.07.31 | 379 |
| 5 |
Ionic을 이용한 iOS, Android 하이브리드 앱 개발 사례
| 졸리운_곰 | 2016.07.31 | 550 |
| 4 |
Ionic Framework를 이용하여 하이브리드앱 개발하기
| 졸리운_곰 | 2016.07.31 | 284 |
| 3 |
Build a mobile app with Ionic + WordPress
| 졸리운_곰 | 2016.06.06 | 362 |
| 2 |
Create a Mobile Application Using WordPress, Ionic, and AngularJS
| 졸리운_곰 | 2016.06.06 | 10185 |
| 1 |
Ionic Framework를 이용하여 하이브리드앱 개발하기
| 졸리운_곰 | 2016.06.06 | 426 |

