Msm8937+android7.1.1编译环境搭建及编译
1. 硬件配置建议如下:
内存>=16GB
CPU>=i7 四核
2. 软件配置如下:
系统:Ubuntu16.04
JDK:open jdk 1.8
3.环境安装:
更换默认shell,使用下面命令:
sudo rm /bin/sh &&sudo ln -sn /bin/bash /bin/sh
其他环境安装,使用下面命令:
sudo apt-get installlibtool openssh-server samba git-core g++ make
diffstat texi2htmltexinfo subversion gawk chrpath libsm6 libxrender1
libfontconfig1
Sudo apt-get installgnupg flex bison gperf build-essential zip curl
zlib1g-dev libc6-devlib32ncurses5-dev lib32z1 lib32ncurses5
x11proto-core-devlibx11-dev libreadline-gplv2-dev lib32z1-dev
libgl1-mesa-devg++-multilib binutils-mingw-w64 tofrodos
python-markdownlibxml2-utils xsltproc genisoimage python-imaging bc
在安装过程发现安装部分失败,比如在sudoapt-get install subversion,提示unableto locate package subversion,需要变更下载源(Downdfrom这里),之前是china,我变更为这个,但变更时间挺长的,用aliyun可能更好,下载速度更快。
5. 编译
5.1 user 版本编译方法
sourcebuild/envsetup.sh
lunchmsm8937_64-user
make -j16
5.2 debug 编译方法
sourcebuild/envsetup.sh
lunchmsm8937_64-userdebug
make -j16
也可以用./buils.shmsm8937_64 -v user,还可以是eng和userdebug
5.3 编译的问题
如果编译机器的内存<=8GB,会提示
[ 30% 21418/71006]Building with Jack:...k_intermediates/with-local/classes.dex
FAILED: /bin/bashout/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp
Out of memory error(version 1.2-rc4 'Carnac' (298900f95d7bdecfceb327f9d201a1348397ed8a843843 [email protected])).
GC overhead limitexceeded.
Try increasing heapsize with java option '-Xmx
Warning: This mayhave produced partial or corrupted output.
[ 30% 21418/71006]Building with Jack:...http.legacy_intermediates/classes.jack
ninja: buildstopped: subcommand failed.
build/core/ninja.mk:148:recipe for target 'ninja_wrapper' failed
make: ***[ninja_wrapper] Error 1
jack的log文件位于$HOME/.jack-server/logs文件夹下(编译android之前/目录下没有.jack-server和.jack-settings),比如jack-server-0-0.log
解决方案
报错分析:Jack“Out of memory error”
详细的错误日志如下
Out of memory error(version 1.2-rc4 'Carnac' (298900f95d7bdecfceb327f9d201a1348397ed8a843843 [email protected])).
GC overhead limitexceeded.
Try increasing heapsize with java option '-Xmx
Warning: This mayhave produced partial or corrupted output.
详细的错误日志里边列出了问题并且已经给出了解决方案- 增加Java虚拟机的-Xmx大小,即设置一个较大的堆内存上限。
可以修改Jack的配置文件prebuilts/sdk/tools/jack-admin。
这是一个管理Jack的shell脚本,直接修改其启动参数,由原来的改为:
JACK_SERVER_VM_ARGUMENTS=
"-Dfile.encoding=UTF-8-XX:+TieredCompilation –Xmx4096m"
JACK_SERVER_VM_ARGUMENTS="${JACK_SERVER_VM_ARGUMENTS:=-Dfile.encoding=UTF-8-XX:+TieredCompilation -Xmx4096M}"
JACK_SERVER_COMMAND="java-XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR$JACK_SERVER_VM_ARGUMENTS -Xmx4096M -cp$LAUNCHER_JAR $LAUNCHER_NAME"
红色部分是增加的。
此时Jack服务器仍然在后台执行,所以我们需要将其停止,然后重启启动(make会自动启动Jack服务器)才能使得修改后的参数生效。
jack server 运行和开启
./jack-admin kill-server
./jack-admin start-server
然后我们重新执行make -jN命令(N是你前边设置的并行任务数量)开始编译。我们这里是
make-j8
参考链接:
http://blog.csdn.net/u012915455/article/details/52382630#51-jack-out-of-memory-error
http://stackoverflow.com/questions/42935822/android-jack-error-no-mapping-specified-for-register
http://blog.csdn.net/xz10561/article/details/53886691
http://blog.csdn.net/lizekun2010/article/details/52535591