AOSP源码编译Ubuntu

Aosp官方教程
Ubuntu18.0.4下载ubuntu-18.04.5-desktop-amd64.iso

创建Ubuntu虚拟机

自定义高级=>安装程序光盘映像文件(iso)=>输入虚拟机名称、账号密码=>各种虚拟机配置=>创建新虚拟磁盘=>将虚拟磁盘拆分成多个文件=>耐心等待

为Ubuntu开启ssh服务
//查看是否安装ssh服务,若出现connect to host localhost port 22: Connection refused则表示未开启ssh服务
ssh localhost ssh
//开启ssh服务
sudo apt-get install openssh-server
//启动ssh服务
sudo /etc/init.d/ssh start
设置ubuntu为静态ip

ifconfig查看网卡名称


网卡名称

1.sudo nano /etc/network/interfaces 修改内容为:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet static
address 192.168.1.23
netmask 255.255.255.0
gateway 192.168.1.99

2.sudo nano /etc/resolv.conf 修改内容为nameserver 8.8.8.8
3.service networking restart 重启网卡,如果报错直接重启电脑,然后再按照第2部操作即可。

安装中文输入法
sudo apt-get install fcitx-bin
sudo apt-get install fcitx-table

打开ubuntu的settings=>Region&Language=>Manage Installed Languages=>RemindMeLater


image.png

先点击Install/Remove Language,把Chineses(simplified) 选进去后,点apply,再点Apply system-wide后重启系统


image.png

运行apt get报错如下:

E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

可以这样解决:

sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
aosp8.1.0+ubuntu18.0.4 源码编译

安装依赖:

sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig

修改为中科大源

//进入到/etc/apt:备份sources.list
ruin@ubuntu:/etc/apt$ sudo cp sources.list sources.list.bak
nano sources.list添加sources.list的源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

更新源

sudo apt-get update

安装python

//确保python2和python3都安装
apt-get install python
apt-get install python3

安装 Repo

sudo nano /etc/profile
export PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

同步中科大源aosp版本号
中科大aosp开源镜像

// cd到自己创建的目录
cd /home/ruin/Desktop/AOSP8.1.0
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.1.0_r1 

如果遇到下面错误,则需要编辑bash.rc,然后退出终端再打开终端

fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 110] Connection timed out
fatal: cloning the git-repo repository failed, will remove '.repo/repo' 

ruin@ubuntu:~$ sudo nano .bashrc
//把下面命令复制到.bashrc文件中并重启终端
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

重新运行repo,并设置邮箱

git config --global user.email "[email protected]"
git config --global user.name "Ruin"
PATH=~/bin:$PATH
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.1.0_r1

下载源码

ruin@ubuntu:~/Desktop/AOSP8.1.0$repo sync -j4

你可能感兴趣的:(AOSP源码编译Ubuntu)