MacOS Sierra10.12.4编译Android7.1.1源码必须跳的坑
来源:互联网 发布:vm虚拟机装mac 编辑:程序博客网 时间:2024/06/05 01:40
简介
下载Android7.1.1源码花费了两天,编译整个源码同样花费了2天,期间遇到无数个坑。现在编译源码,一旦中间遇到错误,则要重新开始。本文记录编译过程遇到的问题及解决方案,如有编译源码需求的可以参考本文先把这些坑跳过然后再编译,Mac环境为10.12.4.
编译步骤
直接参考官方指导即可https://source.android.com/source/initializing.html
这些步骤其中暗含深坑,下面将一一解说.
问题1–Mac上大小写不敏感
在Mac上默认是大小写不敏感的,即你新建个a
文件夹和A
文件夹,两者会认为是一个文件夹,不让其创建第二个A
。
由于不舍得在笔记本上开40G空间,我是在移动硬盘上建了个50G的dmg,然后挂载到/Volumes/android
路径下。可以按官方网档用命令建dmg,也可以用自带的磁盘工具来完成。打开磁盘工具,然后点击文件–新建:
接着把格式选成Mac OS扩展(区分大小写,日志式)
建好符合格式要求的dmg后,把源码拷贝到/Volumes/android
就可以了.
问题2–JDK版本问题
编译前请检查JDK版本,看官网上的说明:
Java Development Kit (JDK)Please note, since there are no available supported OpenJDK 8 packages for Ubuntu 14.04, the Ubuntu 15.04 packages must be installed manually. See JDK for Ubuntu LTS 14.04 for precise instructions.The master branch of Android in AOSP: Ubuntu - OpenJDK 8, Mac OS - jdk 8u45 or newerAndroid 5.x (Lollipop) - Android 6.0 (Marshmallow): Ubuntu - OpenJDK 7, Mac OS - jdk-7u71-macosx-x64.dmgAndroid 2.3.x (Gingerbread) - Android 4.4.x (KitKat): Ubuntu - Java JDK 6, Mac OS - Java JDK 6Android 1.5 (Cupcake) - Android 2.2.x (Froyo): Ubuntu - Java JDK 5
在Mac OS上需要jdk 8u45
之后的版本,如果版本低于这个,将会报一个错。我索性安装的最新的,直接1.8.0_112
:
~ echo $JAVA_HOME/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
问题3–fatal error: linux/netfilter/xt_DSCP.h: No such file or directory
详细报错信息如下:
In file included from out/target/product/generic/obj/STATIC_LIBRARIES/libext4_intermediates/libipt_ECN.c:11:0:external/iptables/extensions/../include/linux/netfilter_ipv4/ipt_ECN.h:13:37: fatal error: linux/netfilter/xt_DSCP.h: No such file or directory #include <linux/netfilter/xt_DSCP.h> ^compilation terminated.make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libext4_intermediates/libipt_ECN.o] Error 1make: *** Waiting for unfinished jobs....
解决方法,在对应目录下新建xt_DSCP.h
文件:
/* based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <mgm@paktronix.com> * This software is distributed under GNU GPL v2, 1991 * * See RFC2474 for a description of the DSCP field within the IP Header. * * xt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp*/#ifndef _XT_DSCP_TARGET_H#define _XT_DSCP_TARGET_H#include <linux/netfilter/xt_dscp.h>#include <linux/types.h>/* target info */struct xt_DSCP_info { __u8 dscp;};struct xt_tos_target_info { __u8 tos_value; __u8 tos_mask;};#endif /* _XT_DSCP_TARGET_H */
问题4–Unsupported curl
问题详情:
Unsupported curl, please use a curl not based on SecureTransportJack server installation not foundUnsupported curl, please use a curl not based on SecureTransportUnsupported curl, please use a curl not based on SecureTransport[ 27% 12844/46181] host Java: bouncycastle-host (out/host/common/obj/JAVA_LIBRARIES/bouncycastle-host_intermediates/classes)
需要重新装curl:You need install a curl compiled with openssl
从http://curl.haxx.se/download.html下载,然后:
./configure --prefix=/usr/local/curl --with-ssl=/usr/local/Cellar/openssl/1.0.2d_1make && make install
然后将/usr/local/curl/bin
添加到PATH,通过一下验证是否安装好curl:
$ curl --versioncurl 7.46.0 (x86_64-apple-darwin15.2.0) libcurl/7.46.0 OpenSSL/1.0.2d zlib/1.2.5Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets
问题5–jack-admin Out of memory error
如果是默认设置的话,一定会遇到这个问题,详细log:
FAILED:Jack server failed to (re)start, try 'jack-diagnose' or see Jack server logNo Jack server running. Try 'jack-admin start-server'……ninja: build stopped: subcommand failed.make[1]: *** [ninja_wrapper] Error 1
参考http://blog.csdn.net/luvzhan/article/details/53282968,解决方法编辑prebuilts/sdk/tools/jack-admin
文件,在JACK_SERVER_COMMAND=“…… -cp ……” -cp
前添加-Xmx7000m
,(7000m为内存大小的一半左右,根据所用的主机配置而定)。
切记:之后再编译前一定要手动开启jack-admin start-server
也可以参考官网里的一段:
If you experience Jack compilations failing on Out of memory error.:You can improve the situation by reducing the number of jack simultaneous compilations by editing your $HOME/.jack-server/config.properties and changing jack.server.max-service to a lower value and then restarting the server.If this is not enough, you may change the arguments used to start the server jvm and force a greater maximum Java heap size (“-Xmx”):Stop the server using jack-admin stop-server, then:If you start the server manually:JACK_SERVER_VM_ARGUMENTS="-Xmx2g -Dfile.encoding=UTF-8 -XX:+TieredCompilation" jack-admin start-serverIf you use the jack server in the android tree thenexport ANDROID_JACK_VM_ARGS="-Xmx2g -Dfile.encoding=UTF-8 -XX:+TieredCompilation"and restart your build command.
事实上这里是一个意思,我建议直接修改jack-admin
文件.
问题6–error: 'syscall' is deprecated
在MacOSX10.11
之后的平台上编译源码会遇到这个问题,解决方法是从https://github.com/phracker/MacOSX-SDKs下载MacOSX10.11
,
解压拷贝到/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
。为了避免下次升级的时候再被删除,可以放到一个自己的目录(/Users/xu/work/git/MacOSX-SDKs/
),再给它创建一个软链接:
sudo ln -s /Users/xu/work/git/MacOSX-SDKs/MacOSX10.11.sdk /Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
然后确保AOSP源码下build/core/combo/mac_version.mk
文件中
mac_sdk_versions_supported := 10.9 10.10 10.11
后面不要写10.12.
问题7–不要忘了下载驱动
如果你想将编译后的镜像安装到手机,编译源码前不要忘了下载驱动:https://developers.google.com/android/blobs-preview或https://developers.google.com/android/drivers#angler下载。
编译核心命令
- 手动开启jack-admin(尽量手动开启)
$ jack-admin kill-server$ jack-admin start-server
- 清空
make clobber
- 设置环境
source build/envsetup.sh
- 选择target
lunch
- 开始编译
make -j4
参考
- http://blog.csdn.net/sinat_26227857/article/details/44078703
- 问题4解决方法
- 问题5 官网jack-admin
- 问题5 csdn博客
- 问题6
- MacOS Sierra10.12.4编译Android7.1.1源码必须跳的坑
- 编译Android7.1.1
- Android7.0源码编译运行指南
- Android7.0源码下载,编译,运行
- Android7.0源码编译运行指南
- android7.0 源码编译问题总结
- Android7.0源码编译运行指南
- hadoop2.4.0在macos下编译源码
- Android 源码编译 MacOS X环境
- MacOS 下源码编译TensorFlow (GPU版本)
- imx6 android7.1.1 源码下载
- 记录一下最近android7.1.1编译出现的问题
- Windows平台上Android Studio上编译Google的Android7源码中的Settings
- 【Android7.1.2源码解析系列】android init目录下的Android.mk编译文件分析
- Ubuntu 17.04上编译android7.1.1
- 修改Android7.1.1源码改变SwitchButton样式
- [Mac] macOS Sierra源码编译安装Mysql Utilities 1.6
- SDL在MACOS下的编译
- spring工作原理
- [HDU2457]DNA repair-AC自动机
- JS封装的含义及通俗比喻
- hdu 1484 Basic wall maze bfs + 输出路径
- (int*)(&a+1)
- MacOS Sierra10.12.4编译Android7.1.1源码必须跳的坑
- 报表绘图插件echarts使用教程
- ajax data的参数
- 【unity实用技能】unity编辑器工具之加载预制(Prefab)和场景(Scene)
- A Sample Socket-Based Activation
- 展示一款创视微前年开发的互联网家庭k歌硬件MC-1
- 欢迎使用CSDN-markdown编辑器
- 密集芯片的焊接技巧:从LQFP64说起
- 多层布局禁止底层获取点击事件