不飞则已,一飞冲天;不鸣则已,一鸣惊人。这篇文章主要讲述Ubuntu16.04配置Android5.0编译环境相关的知识,希望能为你提供帮助。
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
文章图片
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-dev:i386
编译过程中出现如下错误:
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 < source_android> /art/build/Android.common_build.mk //修改第119行
修改前:
# Host.
【Ubuntu16.04配置Android5.0编译环境】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 < source_android> /prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/ld
推荐阅读
- 城管APP开发建立新的城管系统新模式
- appium测试之获取appPackage和appActivity
- 第二节课-Data-driven approach:KNN和线性分类器分类图片
- Android添加项目编译.
- Android:子线程向UI主线程发送消息
- 比较pagerequestsessionapplication的使用范围(转自用)
- Cause: java.lang.ClassCastException: java.lang.String cannot be castto org.apache.ibatis.mapping.M
- Android(制作Update.zip升级包)
- 用树莓派改装电风扇及实现Android500.gs遥控