Môi trường build (đã test OK)
- OS: Ubuntu 16.04 64 bit
- CPU: 4 core x 2.2GHz
- RAM: 16Gb
- SSD: 250Gb
Setup môi trường
– Update package manager của Ubuntu
1 |
sudo apt-get update |
1 2 3 |
mkdir -p ~/bin wget 'https://storage.googleapis.com/git-repo-downloads/repo' -P ~/bin chmod +x ~/bin/repo |
1 |
sudo apt-get install git -y |
1 |
sudo apt-get install openjdk-8-jdk android-tools-adb bc bison build-essential curl flex g++-multilib gcc-multilib gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc yasm zip zlib1g-dev -y |
Download AOSP source code
– Tạo folder chứa source
1 |
mkdir -p ~/aosp |
1 2 |
cd ~/aosp repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r34 |
Lệnh repo init ở trên sẽ tải xuống file XML có tên là manifest chứa thông tin về tất cả các git repository và version tương ứng cấu thành nên AOSP. Nếu bạn muốn giới hạn dung lượng tải xuống, bạn có thể đặt độ sâu phiên bản tải xuống thành 1
1 |
repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r34 --depth=1 |
1 |
repo sync -j8 |
Lệnh này sẽ bắt đầu download tất cả các repository cần thiết. Tùy tốc độ mạng có thể mất vài giờ hoặc cả một ngày để việc download hoàn tất.
Build Car Emulator image
– Setup cache cho compiler
1 2 |
export USE_CCACHE=1 prebuilts/misc/linux-x86/ccache/ccache -M 15G |
1 |
export ANDROID_JACK_VM_ARGS="-Xmx6g -Dfile.encoding=UTF-8 -XX:+TieredCompilation" |
1 |
source build/envsetup.sh |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
tuanpm3@aosp:/home/tuanpm3/aosp/ # source build/envsetup.sh including device/asus/fugu/vendorsetup.sh including device/generic/car/vendorsetup.sh including device/generic/mini-emulator-arm64/vendorsetup.sh including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh including device/generic/mini-emulator-mips64/vendorsetup.sh including device/generic/mini-emulator-mips/vendorsetup.sh including device/generic/mini-emulator-x86_64/vendorsetup.sh including device/generic/mini-emulator-x86/vendorsetup.sh including device/generic/uml/vendorsetup.sh including device/google/dragon/vendorsetup.sh including device/google/marlin/vendorsetup.sh including device/google/muskie/vendorsetup.sh including device/google/taimen/vendorsetup.sh including device/huawei/angler/vendorsetup.sh including device/lge/bullhead/vendorsetup.sh including device/linaro/hikey/vendorsetup.sh including sdk/bash_completion/adb.bash |
1 |
lunch aosp_car_x86_64 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=9 TARGET_PRODUCT=aosp_car_x86_64 TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_ARCH=x86_64 TARGET_ARCH_VARIANT=x86_64 TARGET_2ND_ARCH=x86 TARGET_2ND_ARCH_VARIANT=x86_64 HOST_ARCH=x86_64 HOST_2ND_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-4.4.0-142-generic-x86_64-Ubuntu-16.04.6-LTS HOST_CROSS_OS=windows HOST_CROSS_ARCH=x86 HOST_CROSS_2ND_ARCH=x86_64 HOST_BUILD_TYPE=release BUILD_ID=PQ2A.190305.002 OUT_DIR=out |
1 |
make -j8 |
lệnh trên sẽ thực hiện build source với 8 thread (số thread được chỉ định thông thường sẽ = 2 x số core vật lý của CPU). Thời gian build sẽ mất một vài giờ đồng hồ. Giờ là lúc chúng ta đi uống vài tách cafe hoặc trà đá trước khi quay trở lại. Sau khi build thành công màn hình sẽ display như sau →
1 2 3 4 |
... The new table will be used at the next reboot. The operation has completed successfully. #### build completed successfully (01:56:37 (hh:mm:ss)) #### |
Chạy Car Emulator
Các image output sẽ nằm trong aosp/out/target/product/generic_x86_64/- ramdisk.img: Chính là root filesystem, được generated từ folder /root
- system.img: Image sẽ được mount vào /system trên root filesystem, chứa thư viện của framework và system applications
- userdata.img: Image sẽ được mount vào /data trên root filesystem, chứa userdata
1 |
emulator |
Android Car emulator
Để chạy emulator trên Windows mình sẽ hướng dẫn ở bài khác.— Phạm Minh Tuấn (Shun) —