pre

sudo apt-get install -y openjdk-8-jdk
sudo apt-get install -y git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip

download

git

sudo apt install git
git config --global user.name "xyz"
git config --global user.email "xyz@gmail.com"

ethstatus

sudo apt install -y ethstatus net-tools

use ifconfig to get your net name, may be it looks like wlp4s0, then use ethstatus -i wlp4s0 to get net status.

repo

mkdir ~/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo
chmod +x ~/bin/repo
mkdir -p ~/source/android-10
vim ~/repo_sync.sh

#!/bin/bash

export PATH=$PATH:~/bin 
export REPO_URL="https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/"

cd ~/source/android-10
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-10.0.0_r8
repo sync

compile

vim build_aosp.sh
#!/bin/bash

cd source/android-10/
source build/envsetup.sh
lunch aosp_x86_64-eng

#make system-api-stubs-docs-update-current-api

if error with 1 or 137, the ram may be less than needed, you should increase swap size or ram size.

emulator

vim emulator.sh

#!/bin/bash

cd source/android-10/

source build/envsetup.sh
lunch aosp_x86_64-eng

#sudo emulator
emulator

if error is "Please ensure KVM is properly installed and usable." you need:

  1. sudo apt install -y qemu-kvm cpu-checker
  2. use kvm-ok to check the kvm has already?
  3. use usermod -a -G kvm xyz to add user: xyz in kvm group.
  4. user echo 'KERNEL=="kvm",GROUP="kvm",MODE="0660"' >> /etc/udev/rules.d/androidUseKVM.rules to add kvm rules.
  5. reboot or relogin

if still has the error like "grant current user access to /dev/kvm", "/dev/kvm devices: permission denies", then sudo chown xyz -R /dev/kvm

reference:

Ubuntu 18.04 emulator运行Android源码编译的 X86 虚拟机image
https://blog.csdn.net/csusunxgg/article/details/81060890
Ubentu编译Android源码(AOSP)
https://www.cnblogs.com/caoxinyu/p/10568480.html

标签: aosp

添加新评论