標籤:cloud tar included target pen map conf 需求 ipv6
簡單介紹
下載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 <[email protected]> * 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原始碼必須跳的坑