Ubuntu16.04配置Android5.0编译环境

 

 

1、安装jdk7

Ubuntu16.04的安装源已经默认没有openjdk7了,所以要自己手动添加仓库,如下:

$ sudo add-apt-repository ppa:openjdk-r/ppa

$ sudo apt-get update

安装openjdk-7-jdk

$ sudo apt-get install openjdk-7-jdk openjdk-7-jre

如果安装成功之后还是不能用可能有多个版本,执行如下命令选择正确的版本:
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

查看Java
版本信息:

$ java  -version

clip_image001

 

2、安装编译所需的依赖

以下提到的编译需要依赖的程序,请务必确认每个都安装成功

sudo apt-get update

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 libc6-dev-i386 
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev 
sudo apt-get install lib32z-dev ccache 
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4

 

如果安装过程中出现错误,务必逐个搜索解决方案,可能某些程序的版本有变动:

例如 :lib32z-dev 有可能需要安装:lib32z-devi386

 

 

编译过程中出现如下错误:

libnativehelper/JniInvocation.cpp:40: error: unsupported reloc 43

libnativehelper/JniInvocation.cpp:45: error: unsupported reloc 43

libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43

libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43

libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43

libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43

clang: error: linker command failed with exit code 1 (use -v to see invocation)

host C++: libc++ <= external/libcxx/src/algorithm.cpp

host C++: libc++ <= external/libcxx/src/bind.cpp

build/core/host_shared_library_internal.mk:44: recipe for target 'out/host/linux-x86/obj32/lib/libnativehelper.so' failed

make: *** [out/host/linux-x86/obj32/lib/libnativehelper.so] Error 1

 

解决方法:

source_android代表你的android源码根目录

 

setp1:

 

vim /art/build/Android.common_build.mk    //修改第119

修改前:

# Host.

ART_HOST_CLANG := false

ifneq ($(WITHOUT_HOST_CLANG),true)

# By default, host builds use clang for better warnings.

ART_HOST_CLANG := true

endif

修改后:

# Host.

ART_HOST_CLANG := false

ifneq ($(WITHOUT_HOST_CLANG),false)

# By default, host builds use clang for better warnings.

ART_HOST_CLANG := true

endif

 

setp2:

 

cp  /usr/bin/ld.gold   /prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/ld

 

 

 

 

 

转载于:https://www.cnblogs.com/LoTGu/p/7350939.html

你可能感兴趣的:(Ubuntu16.04配置Android5.0编译环境)