※ 다음은 리눅스에서 안드로이드 emulator를 build 하는 방법임.
1. 안드로이드 에뮬레이터 최신 소스를 다운 받는다.
다운로드 :
http://android.googlecode.com/files/android-emulator-m3-rc37.tar.bz2
2. 압축을 푼다.
> bzip2 -d android-emulator-m3-rc37.tar.bz2
> tar xvf android-emulator-m3-rc37.tar
3. Compile을 한다.
> cd /android-emulator-20071212
> ./build-emulator.sh
이 과정에서 두가지의 Bug가 발생할 수 있음.
1> CLOCK_MONOTONIC Not Defined Error 발생시
qemu/vl.c 의 659 라인과 678 라인을 다음과 같이 바꾼다.
- #if defined(__linux__)
+ #if 0 // defined(__linux__)
2> XRRSetScreenConfig 에 대한 different prototype Error 발생시
sdl/src/video/x11/SDL_x11sym.h 의 195 라인을 다음과 같이 바꾼다.
- SDL_X11_SYM(Status,XRRSetScreenConfig,(Display *dpy, XRRScreenConfiguration *config,
Drawable draw, int size_index,
Rotation rotation, Time timestamp),
(dpy,config,draw,size_index, rotation,timestamp),return)
+ SDL_X11_SYM(Status,XRRSetScreenConfig,(Display *dpy, XRRScreenConfiguration *config,
Drawable draw, int size_index, int visual_group_index,
Rotation rotation, Time timestamp),
(dpy,config,draw,size_index, visual_group_index, rotation,timestamp),return)
sdl/src/video/x11/SDL_x11modes.c 의 255 라인과 1083라인을 다음과 같이 바꾼다.
- XRRSetScreenConfig(SDL_Display, screen_config, SDL_Root,
size_id, saved_rotation, CurrentTime);
+ int visual_group_index = 0;
+ XRRSetScreenConfig(SDL_Display, screen_config, SDL_Root,
size_id, visual_group_index, saved_rotation, CurrentTime);
4. 3과 같이 Patch 한 후 다시 Build한다.
> ./build-emulator.sh
5. emulator를 실행하기 위한 안드로이드 kernel image 및 기타 화면 skin등을 설치한다.
Windows 용으로 Release되고 있는 android_sdk_windows_m3-rc37a 의 tools/lib 디렉터리를 압축하여
Linux의 emulator가 있는 디렉토리에 푼다.
6. emulator를 실행한다.
> ./emulator
7. 6위 과정에서 다음과 같은 오류가 발생할 수 있다.
qemu: fatal: Bad mode 8
이 오류는 emulator의 두 구성요소, 즉 SDL과 QEMU중 QEMU를 GCC3.X.X 버전으로 빌디하지 않았기 때문이다.
이를 해결하기 위해서는 다음과 같이 해결한다.
먼저 GCC 3.X.X 버전을 다운로드 받는다
다운로드 :
ftp://ftp.kaist.ac.kr/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2
그리고 qemu 디렉토리에 GCC를 Compile 하여 설치한다.
> bzip2 -d gcc-3.4.6.tar.bz2
> tar xvf gcc-3.4.6.tar
> cd gcc-3.4.6
> ./configure --prefix=[emulator 설치 Directory]/qemu
> make
> make install
GCC 3.4.6 버전이 설치 완료되면 qemu/config-host.mak를 다음과 같이 수정한다.
- CC=gcc
+ CC=[emulator 설치 Directory]/qemu/bin/gcc
- HOST_CC=gcc
+ HOST_CC=[emulator 설치 Directory]//qemu/bin/gcc
emulator를 새롭게 Build한다.
> cd qemu
> make clean
> make
> cp arm-softmmu/qemu-system-arm ../emulator
8. emulator를 다시 실행한다.
> ./emulator
(위의 그림은 emulator -debug-kernel로 실행한 결과화면과 consol을 함께 capture한 사진임.)