MacOS 10.13.2 下載編譯 android-6.0.1_r81 踩坑記錄

Mac環境: MacOS 10.13.2 

Xcode9.2 (這裏是個大坑, xcode 9 有bug, 後來換成了Xcode 8.3.3)

Android 源碼版本: 6.0.1

JDK: 1.7

下載用的清華鏡像https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/?utm_source=tuicool&utm_medium=referral

編譯參考:http://blog.csdn.net/loften_93663469/article/details/51503293

1. 編譯階段大坑

 

n file included from external/libcxx/src/any.cpp:10: In file included from external/libcxx/include/experimental/any:84:

external/libcxx/include/cstdlib:167: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:115:44: note: target of using declaration

inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT

{return labs(__x);} ^

解決方案, 換低版本的Xcode 8.3.3 , 原始鏈接:https://stackoverflow.com/questions/47060910/error-declaration-conflicts-with-target-of-using-declaration-already-in-scope

2.  xt_DSCP.h 居然找不到了. 參考:http://www.bijishequ.com/detail/366928

報錯信息

 

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把以下代碼放到

external/iptables/include/linux/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 */

 

 

 

 

 

3. 導入Android Studio 參見:http://blog.csdn.net/zhbpd/article/details/48008601

跟目錄運行下面三行命令就好了

source build/envsetup.sh
mmm development/tools/idegen
development/tools/idegen/idegen.sh

 

 

最後附上修改的環境變量~/.bash_profile 如果沒有這個文件要新建一個

 

# 如果有REPO_URL環境變量 ,會替換repo原始的google地址
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'

# export PATH=/opt/local/bin:$PATH
export PATH=/opt/local/bin:$PATH

#如果編譯Android 7.0 以上版本, 要使用java1.8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
# export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
export JAVA_HOME
CLASS_PATH="$JAVA_HOME/lib"
PATH=".$PATH:$JAVA_HOME/bin"

#set the number of open files to be 1024
ulimit -S -n 1024

 

參考:

repo 強制回退

https://blog.csdn.net/zhonglunshun/article/details/75332809

 

 

 

 

 

 

 

 

 


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章