Ubuntu16.04中编译Android6.0源码及注意事项
分类:Android, Java
阅读 (2,447)
Add comments
4月 082017
一、下载Android6.0源码
大家可以从清华的镜像站下载源码库,具体参数https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/和网络上的教程
二、安装编译时需要的软件
直接连接Ubuntu速度比较慢,而且Ubuntu官方没有openjdk7的安装包了,所以更换更新源到国内的源,我把阿里和163的源都放进去了
1.先备份更新源
1 |
cp /etc/apt/sources.list /etc/apt/sources.list.20170405 |
2. 增加阿里的源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse |
3. 增加163的更新源
1 2 3 4 5 6 7 8 9 10 |
deb http://mirrors.163.com/ubuntu/ vivid main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ vivid-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ vivid-backports main restricted universe multiverse |
4. 执行一行apt-get update
1 |
sudo apt-get update |
5. 安装编译时需要的软件
1 2 |
sudo apt-get install openjdk-7-jdk sudo apt-get install curl g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev libxml2-utils |
三、开始编译
四、常见错误及解决办法
1.编译时出现unsupported reloc 43,解决方法如下:
It works to me:
in file /art/build/Android.common_build.mk, find out:
1 2 3 4 5 6 7 |
# Host. ART_HOST_CLANG := false ifneq ($(WITHOUT_HOST_CLANG),true) # By default, host builds use clang for better warnings. ART_HOST_CLANG := true endif |
change to :
1 2 3 4 5 6 7 |
# Host. ART_HOST_CLANG := false ifeq ($(WITHOUT_HOST_CLANG),false) # By default, host builds use clang for better warnings. ART_HOST_CLANG := true endif |
If it still not works,try this in your android root path: cp /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/ld