MacOS Sierra10.12.4編譯Android7.1.1原始碼必須跳的坑

來源:互聯網
上載者:User

標籤: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下載。

編譯核心命令
  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原始碼必須跳的坑

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.