Android 源碼 (AOSP) - 編譯 ( Mac )

前言

上章下完了代碼, 這章來搞編譯
編譯坑是最多的, 我統(tǒng)一放在后面了, 如果遇到問題,可以先看一下是否我這邊已經(jīng)有解決方法了.

在這里插入圖片描述

開搞,開搞.

AOSP系列

開搞

自己的配置

硬件
Mac mini (Late 2014)
2.6 GHz i5
8G 1600 MHz DDR3
自己換了三星的500G固態(tài)硬盤

軟件
系統(tǒng)版本: Mojave 10.14.4

源碼
版本: android-6.0.1_r78

JDK 7

Python
verison: 2.7.10

Git
version 2.21.0

搭建環(huán)境

官網(wǎng)搭建編譯環(huán)境

JDK

下載地址
下載教程blog

android-6.0.1_r78 用的是 JDK 7

MacPorts

安裝了 MacPorts (看官網(wǎng)要求的, 也不知道不安裝會(huì)出現(xiàn)什么錯(cuò)誤不, 當(dāng)時(shí)沒試, 個(gè)人覺得不安裝, 應(yīng)該也沒事, 比較官方的東西有點(diǎn)老)
通過 MacPorts 獲取 Make、Git 和 GPG 程序包:

POSIXLY_CORRECT=1 sudo port install gmake libsdl git gnupg

安裝 bison:

POSIXLY_CORRECT=1 sudo port install bison

磁盤映像

因?yàn)镸ac上的文件系統(tǒng)不能區(qū)分大小寫,所以需要?jiǎng)?chuàng)建區(qū)分大小寫的鏡像。
打開磁盤映像
然后點(diǎn)擊空白映像, 配置如下, blog教程說至少70G, 我為了預(yù)防版本不同, 可能會(huì)包比較大問題, 直接分配100G了.
分配完成, 把源碼移動(dòng)到磁盤內(nèi)

在這里插入圖片描述

在這里插入圖片描述

分配的時(shí)候真的挺卡的...
可能因?yàn)槲译娔X配置太垃圾問題, 20 ~ 30分鐘才完成

雖然 blog 里面說, 先建磁盤, 但我個(gè)人建議, 先下載代碼, 然后看代碼有多大, 再去分.
不然分了磁盤, 再去磁盤里面下載, 但是你們版本不同, 包的大小也會(huì)不同
分配的盤裝不下, 這種情況就很尷尬.
所以我就將這步放在了編譯階段.

編譯

導(dǎo)入腳本環(huán)境

執(zhí)行 envsetup.sh 腳本

. build/envsetup.sh 

如果你再次編譯, 需要清除已編譯的數(shù)據(jù), 可以調(diào)用以下命令

make clobber 

權(quán)限問題

當(dāng)時(shí)下載源碼下來之后, 發(fā)現(xiàn)自己并沒有操作權(quán)限
如果有童鞋也和我一樣, 直接執(zhí)行這個(gè), 把Android源碼這個(gè)文件夾改為所有人都可以讀寫

sudo chmod -R 777 源碼文件夾路徑

選擇要編譯的目標(biāo)

命令行輸入

lunch

然后控制臺(tái)出現(xiàn)

Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     4. aosp_mips64-eng
     5. aosp_x86-eng
     6. aosp_x86_64-eng
     7. aosp_deb-userdebug
     8. aosp_flo-userdebug
     9. full_fugu-userdebug
     10. aosp_fugu-userdebug
     11. mini_emulator_arm64-userdebug
     12. m_e_arm-userdebug
     13. mini_emulator_mips-userdebug
     14. mini_emulator_x86-userdebug
     15. mini_emulator_x86_64-userdebug
     16. aosp_flounder-userdebug
     17. aosp_angler-userdebug
     18. aosp_bullhead-userdebug
     19. aosp_hammerhead-userdebug
     20. aosp_hammerhead_fp-userdebug
     21. aosp_shamu-userdebug

然后問你選擇哪一個(gè), 直接輸入編號(hào)或者名稱都可以.
當(dāng)然, 如果你已經(jīng)知道編譯什么了, 也可以直接lunch帶上參數(shù), 如下:

lunch aosp_arm-eng

開始編譯

開始編譯

-j4 是線程的意思, 并不是越多越好, 根據(jù)你機(jī)器cup的核心來確定: core * 2, 即當(dāng)前cpu的核心的2倍, 是最快的速度.

make -j4

查看自己電腦的core

sysctl machdep.cpu

# 獲取到的信息
machdep.cpu.core_count: 2

那么我們就直接用 core * 2, 就是 make -j4

*** missing separator

不要在 . build/envsetup.sh 的窗口執(zhí)行, 在新的 shell 窗口執(zhí)行 (個(gè)人估計(jì)是一些環(huán)境變量原因)

dalvik/CleanSpec.mk:47: *** missing separator.

后來編譯完成之后, 發(fā)現(xiàn)新窗口的話, 編譯,總是 generic 文件夾, 這個(gè)不應(yīng)該的
想了一下, 肯定是用新窗口, 然后編譯配置是用默認(rèn)的了, 所以還是要解決這個(gè)方法
但是又找了好久, 沒找到解決, 不過可以通過另一種思路去搞.
其實(shí)調(diào)用 lunch xxx 這個(gè)是配置加載數(shù)據(jù)的意思, 那么我們是否能把配置數(shù)據(jù)復(fù)制下來, 然后寫到腳本內(nèi), 直接加載腳本呢, 達(dá)到直接配置的意思呢???
經(jīng)過測(cè)試, 確實(shí)可以的

  1. 例如我把 aosp_x86_64 復(fù)制, 并創(chuàng)建一個(gè) xq_config_aosp_x86_64.sh 文件, 然后寫入以下內(nèi)容
#!/bin/bash

export PLATFORM_VERSION_CODENAME=REL
export PLATFORM_VERSION=6.0.1
export TARGET_PRODUCT=aosp_x86_64
export TARGET_BUILD_VARIANT=eng
export TARGET_BUILD_TYPE=release
export TARGET_BUILD_APPS=
export TARGET_ARCH=x86_64
export TARGET_ARCH_VARIANT=x86_64
export TARGET_CPU_VARIANT=
export TARGET_2ND_ARCH=x86
export TARGET_2ND_ARCH_VARIANT=x86
export TARGET_2ND_CPU_VARIANT=
export HOST_ARCH=x86_64
export HOST_OS=darwin
export HOST_OS_EXTRA=Darwin-18.5.0-x86_64-i386-64bit
export HOST_BUILD_TYPE=release
export BUILD_ID=MOB31S
export OUT_DIR=out

  1. 調(diào)用 make -j4 前, 導(dǎo)入配置
. 路徑/xq_config_aosp_x86_64.sh
  1. 調(diào)用 make -j4

這個(gè)時(shí)候調(diào)用 make -j4 就能看到正常運(yùn)行了, 并且能看到并不是只有 out/target/product/generic 了, 還創(chuàng)建了 out/target/product/generic_x86_64 文件夾

make -j4

大約編譯了兩個(gè)小時(shí), out 文件夾下 6.14 G (看電腦配置)

最后終于大功告成, 編譯完成!!! 以下是成功信息

Preparing output jar [/Volumes/android_source/android_source_back/out/target/common/obj/APPS/messaging_intermediates/proguard.classes.jar]
  Copying resources from program jar [/Volumes/android_source/android_source_back/out/target/common/obj/APPS/messaging_intermediates/classes.jar]
target Dex: messaging
Copying: out/target/common/obj/APPS/messaging_intermediates/classes.dex
target Package: messaging (out/target/product/generic/obj/APPS/messaging_intermediates/package.apk)
warning: string 'done' has no default translation.
warning: string 'done' is missing 90 required localizations: af_ZA am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR fi_FI fr_BE fr_CA fr_CH fr_FR gl_ES gu_IN hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_IT iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pa_IN pl_PL pt_BR pt_PT rm_CH ro_RO ru_RU si_LK sk_SK sl_SI sq_AL sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_PK uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
Warning: AndroidManifest.xml already defines minSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
Warning: AndroidManifest.xml already defines targetSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.
warning: no entries written for string/done (0x7f0e000d)
Install: out/target/product/generic/system/app/messaging/messaging.apk
Install: out/target/product/generic/system/priv-app/Settings/Settings.apk
build/tools/generate-notice-files.py  out/target/product/generic/obj/NOTICE.txt  out/target/product/generic/obj/NOTICE.html "Notices for files contained in the filesystem images in this directory:" out/target/product/generic/obj/NOTICE_FILES/src
Combining NOTICE files into HTML
Combining NOTICE files into text
Installed file list: out/target/product/generic/installed-files.txt
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Running:  mkuserimg.sh out/target/product/generic/system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 1610612736 -D out/target/product/generic/system -L system out/target/product/generic/root/file_contexts
make_ext4fs -T -1 -S out/target/product/generic/root/file_contexts -L system -l 1610612736 -a system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/generic/system out/target/product/generic/system
Creating filesystem with parameters:
    Size: 1610612736
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 6144
    Label: system
    Blocks: 393216
    Block groups: 12
    Reserved block group size: 95
Created filesystem with 1434/98304 inodes and 102834/393216 blocks
Install system fs image: out/target/product/generic/system.img
out/target/product/generic/system.img+ maxsize=1644333504 blocksize=2112 total=1610612736 reserve=16610880

-bash: lunch: command not found

先調(diào)用

. build/envsetup.sh

再執(zhí)行

lunch 

Can not find SDK

Can not find SDK 10.6 at /Developer/SDKs/MacOSX10.6.sdk

網(wǎng)上說法: 把 ==build/core/combo/mac_version.mk== 中的 ==mac_sdk_versions_supported== 版本問題, 只要修改一下, 對(duì)應(yīng)你的 ==/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs== 下面 MacOSX 版本就行了.
但是我這邊試了并不行, 還是得屁顛屁顛跑去下載了低版本 SDKs.

然而下載 10.6 版本會(huì)出現(xiàn)下面這個(gè)問題

DVTSDK: Skipped SDK xxxx; its version (10.6) is below required minimum (10.11) for the macosx platform.

說最少得用 10.11 版本... 好吧, 下載 10.11 版本

DVTSDK: Skipped SDK /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk; its version (10.9) is below required minimum (10.11) for the macosx platform.

如果你 SDKs 里面有 10.6 還是會(huì)提示一大堆東西 ( 是默認(rèn)優(yōu)先去加載 10.6 了??? ), 這個(gè)時(shí)候, 只要把10.6 移除就行了.

JDK

Unable to find any JVMs

該問題是找不到j(luò)ava版本

Unable to find any JVMs matching version "1.7". 

可以先 open /Library/Java/JavaVirtualMachines/
看一下你本機(jī)是否有JDK了, 如果沒有或者版本比Android源碼要求的高, 都去下載, 然后把該 openjdk/Contents/Home 放到環(huán)境內(nèi) ~/.bash_profile

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
export ANDROID_JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home

tools.jar

找不到 tools.jar, 因?yàn)橐婚_始我用的是 12.0.1 版本, 在 JDK9 的時(shí)候, 官方就移除了 tools.jar
所以我們要下載 JDK8, 然后把相對(duì)應(yīng)的 tools.jar 移過來就行 然而經(jīng)自己測(cè)試了一下, 還是有問題, 所以不要搞啥花里胡哨的, 直接下載 JDK 7 (源碼對(duì)應(yīng)JDK)

Error: could not find jdk tools.jar

The required version is: "1.7.x"

JDK 還是報(bào)錯(cuò)說不要用 12.0.1 版本, 這個(gè)下載 JDK 7 就行了

You are attempting to build with the incorrect version
of java.
 
Your version is: openjdk version "12.0.1" 2019-04-16 OpenJDK Runtime Environment (build 12.0.1+12) OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing).
The required version is: "1.7.x"
 
Please follow the machine setup instructions at
    https://source.android.com/source/initializing.html

下載之后, 設(shè)置 ~/.bash_profile

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
export ANDROID_JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home

但是我碰到了, 設(shè)置還是不行
然后先查詢現(xiàn)在的版本

/usr/libexec/java_home -V

設(shè)置版本
其實(shí)就是直接在當(dāng)前命令窗口導(dǎo)入環(huán)境變量, 這個(gè)指標(biāo)不治本, 后來自己再測(cè)了一下, 源碼自己修改了 .bash_profile 文件, 但是沒去導(dǎo)入它 (或者重新打開窗口), 這樣環(huán)境變量就沒有改變 =_=

export JAVA_HOME=`/usr/libexec/java_home -v 1.7.0_80`

再次, 查詢, 很好, 當(dāng)前環(huán)境變量已經(jīng)調(diào)過來了, 然后繼續(xù)執(zhí)行 make -j4

java -version

bison

解決一

bison 有問題, 出現(xiàn) Abort trap: 6
https://blog.csdn.net/camlot_/article/details/86540502
網(wǎng)站說的路徑不太對(duì), 最終自己找到的路徑是 ==/opt/local/bin/bison== , 就是一開始配置環(huán)境 Macports 下載的時(shí)候, 會(huì)下到這個(gè)路徑下
然而如果自己用 brew install Bison 就是在這個(gè)路徑下 /usr/local/Cellar/bison/版本/bin/bison

prebuilts/misc/darwin-x86/bison/bison -d  -o out/host/darwin-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
make: *** [out/host/darwin-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Abort trap: 6
make: *** Waiting for unfinished jobs....
注: 某些輸入文件使用了未經(jīng)檢查或不安全的操作。
注: 有關(guān)詳細(xì)信息, 請(qǐng)使用 -Xlint:unchecked 重新編譯。
注: 某些輸入文件使用了未經(jīng)檢查或不安全的操作。
注: 有關(guān)詳細(xì)信息, 請(qǐng)使用 -Xlint:unchecked 重新編譯。

把 bison 創(chuàng)建一個(gè)快捷方式到某個(gè)路徑下

ln -s 源文件路徑 目標(biāo)路徑

解決二

編譯 8.0 的時(shí)候查出來的

FAILED: out/soong/.intermediates/system/tools/aidl/libaidl-common/darwin_x86_64_static/gen/yacc/system/tools/aidl/aidl_language_y.cpp out/soong/.intermediates/system/tools/aidl/libaidl-common/darwin_x86_64_static/gen/yacc/system/tools/aidl/aidl_language_y.h 
BISON_PKGDATADIR=external/bison/data prebuilts/misc/darwin-x86/bison/bison -d  --defines=out/soong/.intermediates/system/tools/aidl/libaidl-common/darwin_x86_64_static/gen/yacc/system/tools/aidl/aidl_language_y.h -o out/soong/.intermediates/system/tools/aidl/libaidl-common/darwin_x86_64_static/gen/yacc/system/tools/aidl/aidl_language_y.cpp system/tools/aidl/aidl_language_y.yy
[  1% 971/59651] cc out/soong/.intermediates/system/...armv7-a_static_core/obj/system/core/adf/libadf/adf.
ninja: build stopped: subcommand failed.
11:00:22 ninja failed with: exit status 1
make: *** [run_soong_ui] Error 1

網(wǎng)上說到這個(gè)目錄下, 然后更新指定 git 版本, 但是我這邊根本更不了... .git 文件夾就是壞的

cd external/bison
git cherry-pick c0c852bd6fe462b148475476d9124fd740eba160

上面說的copy一個(gè)bison到這個(gè)文件夾, 也是不行的....
后面找到了這個(gè), 自己去編譯一個(gè) bison 出來 (上面的 git cherry-pick 就是打補(bǔ)丁, 而這個(gè)是手動(dòng)打補(bǔ)丁)
https://blog.csdn.net/h649305597/article/details/80322488

  1. 到該文件夾下
cd external/bison
  1. 創(chuàng)建 patch-high-sierra.patch
touch patch-high-sierra.patch
  1. 并把下面代碼復(fù)制進(jìn)去
With format string strictness, High Sierra also enforces that %n isn't used
in dynamic format strings, but we should just disable its use on darwin in
general.

--- lib/vasnprintf.c.orig   2017-06-22 15:19:15.000000000 -0700
+++ lib/vasnprintf.c    2017-06-22 15:20:20.000000000 -0700
@@ -4869,7 +4869,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *
 #endif
                   *fbp = dp->conversion;
 #if USE_SNPRINTF
-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# if !defined(__APPLE__) && !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
                 fbp[1] = '%';
                 fbp[2] = 'n';
                 fbp[3] = '\0';
  1. 在控制臺(tái)(保證當(dāng)前目錄是external/bison)執(zhí)行 (這個(gè)是打補(bǔ)丁的意思??)
patch -p0 < patch-high-sierra.patch
  1. 返回源碼根目錄
cd ../..
  1. 編譯 bison
make bison
  1. 復(fù)制編譯好的 bison 到執(zhí)行位置
cp ./out/host/darwin-x86/obj/EXECUTABLES/bison_intermediates/bison ./prebuilts/misc/darwin-x86/bison/bison 

XcodeDefault.xctoolchain

external/libcxx/include/cstdlib:159:44: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:111:44: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
external/libcxx/include/cstdlib:134:9: note: using declaration
using ::abs;
        ^
external/libcxx/include/cstdlib:161:44: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:113:44: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
external/libcxx/include/cstdlib:134:9: note: using declaration
using ::abs;
        ^
external/libcxx/include/cstdlib:164:42: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
                                         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:116:42: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
                                         ^
external/libcxx/include/cstdlib:139:9: note: using declaration
using ::div;
        ^
external/libcxx/include/cstdlib:166:42: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
                                         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:118:42: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}

20 errors generated.
make: *** [out/host/darwin-x86/obj/STATIC_LIBRARIES/libc++_static_intermediates/src/algorithm.o] Error 1
4 errors generated.
make: *** [out/host/darwin-x86/obj/STATIC_LIBRARIES/libc++_static_intermediates/src/ios.o] Error 1

查了一下, 說需要換低版本XCode
下載 XCode 8.3.3, 好吧, 又是一陣等待
下載好之后, 選中 Xcode_8.3.3 為默認(rèn)

sudo xcode-select -switch /Applications/Xcode_8.3.3.app/Contents/Developer

再次 make -j4

dyld: Symbol not found: _OBJC_IVAR_$_NSTextViewIvars.sharedData
  Referenced from: /Applications/Xcode_8_3_3.app/Contents/SharedFrameworks/DVTDocumentation.framework/Versions/A/../../../../SharedFrameworks/DVTKit.framework/Versions/A/DVTKit
  Expected in: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
 in /Applications/Xcode_8_3_3.app/Contents/SharedFrameworks/DVTDocumentation.framework/Versions/A/../../../../SharedFrameworks/DVTKit.framework/Versions/A/DVTKit
make: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
make: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

然而....又報(bào)錯(cuò), 說不支持, 查了一下, 說 Mojave 不支持 10.0 以下的 XCode... oh my god! 很崩潰! 退版本這個(gè)是不存在的...
好吧, 有點(diǎn)絕望, 各種踩坑, 這個(gè)是弄了最久的, 網(wǎng)上各種資料, 都無法解決.

后來再自己仔細(xì)研究了一下, 其實(shí)這些報(bào)錯(cuò), 是指向 XcodeDefault.xctoolchain

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:118:42

那么是否能通過不替換XCode, 而是替換XCode下面的這個(gè)來作為一個(gè)中轉(zhuǎn)方法呢???
測(cè)試了一下, 是可以了!! (≧▽≦)/

大致就是做兩步

  1. 下載 8.3.3 XCode
  2. 把 8.3.3 XCode 的 XcodeDefault.xctoolchain, 放到現(xiàn)在的 XCode 中, 記得, 不要?jiǎng)h除原有的, 以后還要繼續(xù)用XCode呢, 備份一下. 然后替換掉就行.
在這里插入圖片描述

目前使用下來, 是沒發(fā)現(xiàn)有什么問題
這段時(shí)間沒有打開XCode過, 不知道會(huì)影響 XCode 什么問題, 建議打開XCode 之前, 先把這個(gè)改回來.

xt_DSCP.h

找不到 xt_DSCP.h 文件

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.

修改 external/iptables/include/linux/netfilter_ipv4/ipt_ECN.h 文件

#include <linux/netfilter/xt_DSCP.h>

改成

#include <linux/netfilter/xt_dscp.h>

如果你 linux/netfilter 沒有 xt_dscp.h 文件, 那么可以直接創(chuàng)建 xt_DSCP.h

/* x_tables module for matching the IPv4/IPv6 DSCP field
 *
 * (C) 2002 Harald Welte <laforge@gnumonks.org>
 * 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.3 2002/08/05 19:00:21 laforge Exp
*/
#ifndef _XT_DSCP_H
#define _XT_DSCP_H

#include <linux/types.h>

#define XT_DSCP_MASK    0xfc    /* 11111100 */
#define XT_DSCP_SHIFT   2
#define XT_DSCP_MAX 0x3f    /* 00111111 */

/* match info */
struct xt_dscp_info {
    __u8 dscp;
    __u8 invert;
};

struct xt_tos_match_info {
    __u8 tos_mask;
    __u8 tos_value;
    __u8 invert;
};

#endif /* _XT_DSCP_H */

make update-api

******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
   1) You can add "@hide" javadoc comments to the methods, etc. listed in the
      errors above.

   2) You can update current.txt by executing the following command:
         make update-api

      To submit the revised current.txt to the main Android repository,
      you will need approval.
******************************



make: *** [out/target/common/obj/PACKAGING/checksystemapi-current-timestamp] Error 38

******************************
You have tried to change the API from what has been previously released in
an SDK.  Please fix the errors listed above.
******************************


make: *** [out/target/common/obj/PACKAGING/checksystemapi-last-timestamp] Error 38

根據(jù)提示, 執(zhí)行

make update-api

其他

bash_profile 配置

bash_profile配置, 這里就列一下我的配置吧

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

# wxq Android NDK
#export NDK_HOME=~/android-ndk-r11c
export NDK_HOME=~/Library/Android/sdk/ndk-bundle
export NDK_PROJECT_PATH='/Applications/Android\ Studio.app'
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export PATH=$PATH:$NDK_HOME/
export PATH=$PATH:$ANDROID_SDK_ROOT

# wxq Android 6
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
export ANDROID_JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home


# wxq Android源碼編譯, 在 Mac OS 中,可同時(shí)打開的文件描述符的默認(rèn)數(shù)量上限太低,在高度并行的編譯流程中,可能會(huì)超出此上限。要提高此上限
# set the number of open files to be 1024
ulimit -S -n 1024

# 這個(gè)是下載 MacPorts 自動(dòng)配置上去的
##
# Your previous /Users/wangxingqian/.bash_profile file was backed up as /Users/wangxingqian/.bash_profile.macports-saved_2019-05-20_at_11:34:23
##

# MacPorts Installer addition on 2019-05-20_at_11:34:23: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

參考文章

官網(wǎng)搭建編譯環(huán)境
https://blog.csdn.net/yishon_android/article/details/51726676
https://blog.csdn.net/wd2014610/article/details/81636417

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容