在ubuntu 16.04上编译Android 源码

2016-12-21 07:43:31来源:CSDN作者:zhenxi2735768804人点击

网上有很多编译源码的版本,但是都缺陷,自己工作期间整理一版

1.安装openjdk 三句指令

①sudo add-apt-repository ppa:openjdk-r/ppa
②sudo apt-get update
③sudo apt-get install openjdk-7-jdk

2.安装vim编译器

sudo apt-get install vim

3.配置环境变量

sudo vim /etc/profile
在最下方添加
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
PATH=PATH:HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH



4.安装配置文件
①sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 dpkg-dev


②sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
sudo apt-get install ccache
source ~/.bashrc
5.安装git
sudo apt-get install git
git config –global user.email “941636391@qq.com”
git config –global user.name “Matthew”
6.安装repo 和 wget
sudo apt-get install wget
sudo apt-get install wget –fix-missing
cd /usr/bin/
curl https://storage.googleapis.com/git-repo-downloads/repo
sudo chmod a+x repo
7.同步代码
mkdir android_6.0
cd android_6.0
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-6.0.1_r3
repo sync
根据网速一般是一个小时左右



8.编译
source build/envsetup.sh
lunch 10
makee -j32 iso_img
9.如果报错继续添加库文件
sudo apt-get install libgl1-mesa-dri:i386
wget http://archive.ubuntu.com/ubuntu/pool/universe/m/mingw32-binutils/mingw32-binutils_2.20-0.2ubuntu1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/m/mingw32/mingw32_4.2.1.dfsg-2ubuntu1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/m/mingw32-runtime/mingw32-runtime_3.15.2-0ubuntu1_all.deb
sudo apt-get install -f
sudo dpkg -i *.deb

10.如果还报错,继续添加,不太懂,添加就可以
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib
sudo apt-get install lib32z-dev ccache
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386
sudo lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache

11.报错 recipe for target ’ out/host/linux-x86/obj/lib/libart.so’failed.
在art/build/Android.common_build.mk ,中找到WITHOUT_HOST_CLANG,关闭clang。
ifneq ((WITHOUTHOSTCLANG),true):ifeq((WITHOUT_HOST_CLANG),false)

再进行编译—–> 希望你能成功

微信扫一扫

第七城市微信公众平台