简单介绍

下载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 newer
Android 5.x (Lollipop) - Android 6.0 (Marshmallow): Ubuntu - OpenJDK 7, Mac OS - jdk-7u71-macosx-x64.dmg
Android 2.3.x (Gingerbread) - Android 4.4.x (KitKat): Ubuntu - Java JDK 6, Mac OS - Java JDK 6
Android 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 1
make: *** 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 SecureTransport
Jack server installation not found
Unsupported curl, please use a curl not based on SecureTransport
Unsupported 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_1
make && make install

然后将/usr/local/curl/bin加入到PATH,通过一下验证是否安装好curl:

$ curl --version
curl 7.46.0 (x86_64-apple-darwin15.2.0) libcurl/7.46.0 OpenSSL/1.0.2d zlib/1.2.5
Protocols: 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 log
No 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-server
If you use the jack server in the android tree then
export 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-previewhttps://developers.google.com/android/drivers#angler下载。

编译核心命令

  1. 手动开启jack-admin(尽量手动开启)
$ jack-admin kill-server

$ jack-admin start-server
  1. 清空make clobber
  2. 设置环境source build/envsetup.sh
  3. 选择targetlunch
  4. 開始编译make -j4

參考

  1. http://blog.csdn.net/sinat_26227857/article/details/44078703
  2. 问题4解决方法
  3. 问题5 官网jack-admin
  4. 问题5 csdn博客
  5. 问题6

MacOS Sierra10.12.4编译Android7.1.1源代码必须跳的坑的更多相关文章

  1. macOS Sierra10.12.5 显示允许任何来源

    在终端输入:sudo spctl --master-disable即可.

  2. 在MacOS 10.12上安装Tomcat8.5

    在MacOS 10.12上安装Tomcat8.5 原文链接:https://wolfpaulus.com/journal/mac/tomcat8/ Context 已安装Java,使用java -ve ...

  3. 升级到macOS 10.12 mysqlb报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    系统升级到macOS 10.12后启动mysql后,在终端输入mysql 报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' ...

  4. 对<< ubuntu 12.04编译安装linux-3.6.10内核笔记>>的修正

    前题: 在前几个月的时候,写了一篇笔记,说的是kernel compile的事情,当时经验不足,虽说编译过了,但有些地方写的有错误--因为当时的理解是有错误的.今天一一更正,记录如下: 前文笔记链接: ...

  5. MacOS 10.12 Sierra 安全性与隐私没有任何来源选项解决方法

    MacOS 10.12 Sierra 安全性与隐私没有任何来源选项解决方法 来源: 时间:2016年09月21日 在升级了macOS Sierra (10.12)版本后在“安全性与隐私”中不再有“任何 ...

  6. VBox 安装 macOS 10.12

    安装步骤⑴ 下载及解压 macOS 10.12 Sierra Final by TechReviews.rar ⑵ 下载及双击安装 VirtualBox-5.1.6-110634-Win.exe ,默 ...

  7. 在VS13上编译通过的代码放在12上编译-错误:l __dtoui3 referenced in function _event_debug_map_HT_GROW

    在VS13上编译通过的代码放在12上编译 遇到错误:l __dtoui3 referenced in function _event_debug_map_HT_GROW 1>------ 已启动 ...

  8. macOS 10.12.1 + Xcode 8.1 安装cocoapods 1.1.1

    最近公司刚给配了一台27寸的iMac,5K屏幕,这酸爽~~,新电脑,免不了系统升级,环境搭建,当一切就绪之后,我就准备装cocoapods了,然而,以前所有的教程全部都变得没用了...然而网上一大堆关 ...

  9. nginx-1.12.2编译安装指导

    nginx-1.12.2编译安装 下载源码包 安装 安装后配置 下载源码包 下载地址:http://nginx.org/en/download.html nginx-1.12.2:http://ngi ...

随机推荐

  1. CentOS7 修改主机名

    命令: hostnamectl set-hostname [yourhostname] 不过这种方法,大写会自动变成小写. 还有一种方法,直接修改 /etc/hostname文件,这个可以保证大写不变 ...

  2. fiddler怎么修改服务器返回参数并发送

    在进行使用fiddler中提供了较多的功能进行使用的,那么进行就可以对当前的网页中的暂停之后,在进行使用fiddler中把拦截起的后,在进行修改的服务器参数的之后,在把参数修改完成之后,把进行发送出去 ...

  3. C# 多线程并发锁模式-总结

    开篇: 互斥还是lock Monitor Mutex 模式! Muex Monitor lock AutoEventSet ManualEventSet 后续的 ReaderWriterLock   ...

  4. Swift 互斥锁写法

    oc中的互斥锁@synchronized(self) { //需要执行的代码块} swift中的互斥锁objc_sync_enter(self)//需要执行的代码块objc_sync_exit(sel ...

  5. CocoaAsyncSocket UDP发送数据超过包大小限制(Message too long)

    最近在做iOS上,基于UDP传输音视频时遇到的一个问题,这边纪录一下: 由于考虑实时性比较高,所以采用了 CocoaAsyncSocket 的UDP框架来实现,将视频切割成一帧帧的图片发给服务端,不过 ...

  6. java日期格式(年月日时分秒毫秒)

    package test.remote.tools.combine; import java.text.SimpleDateFormat; import java.util.Calendar; imp ...

  7. hihocoder234周 计算不包含黑点的矩形个数

    题目链接 问题描述 一个棋盘有n条横线,m条竖线,上面有k个黑点,问有多少个不包含黑点的矩形. 数据范围: n和m最大为1000,k最大为10 方法一:动态规划 复杂度n*m*k. import ja ...

  8. vscode用法

    工欲善其事,必先利其器.vscode是一个值得花费时间去掌握精通的编辑器. 好文档不必远求 打开vscode,把菜单看上三遍,仔细思考每个菜单项的作用,思考为啥要这样归类每个菜单项. 配置是系统的核心 ...

  9. numpy二分查找

    a = np.array([1, 2, 2, 3]) print(np.searchsorted(a, 0)) # 0 print(np.searchsorted(a, 1)) # 0 print(n ...

  10. linux shell 脚本攻略学习13--file命令详解,diff命令详解

    一.file命令详解 find命令可以通过查看文件内容来找出特定类型的文件,在UNIX/ Linux系统中,文件类型并不是由文件扩展名来决定的(windows中却正是这么做的),file命令的目的是从 ...