-bash: lunch: command not found
先调用
. build/envsetup.sh
再执行
lunch
Can not find SDK
Can not find SDK 10.6 at /Developer/SDKs/MacOSX10.6.sdk
网上说法: 把 ==build/core/combo/mac_version.mk== 中的 ==mac_sdk_versions_supported== 版本问题, 只要修改一下, 对应你的 ==/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs== 下面 MacOSX 版本就行了. 但是我这边试了并不行, 还是得屁颠屁颠跑去下载了低版本 SDKs.
然而下载 10.6 版本会出现下面这个问题
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 还是会提示一大堆东西 ( 是默认优先去加载 10.6 了??? ), 这个时候, 只要把10.6 移除就行了.
JDK
Unable to find any JVMs
该问题是找不到java版本
Unable to find any JVMs matching version "1.7".
可以先 open /Library/Java/JavaVirtualMachines/ 看一下你本机是否有JDK了, 如果没有或者版本比Android源码要求的高, 都去下载, 然后把该 openjdk/Contents/Home 放到环境内 ~/.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, 因为一开始我用的是 12.0.1 版本, 在 JDK9 的时候, 官方就移除了 tools.jar 所以我们要下载 JDK8, 然后把相对应的 tools.jar 移过来就行 然而经自己测试了一下, 还是有问题, 所以不要搞啥花里胡哨的, 直接下载 JDK 7 (源码对应JDK)
Error: could not find jdk tools.jar
The required version is: "1.7.x"
JDK 还是报错说不要用 12.0.1 版本, 这个下载 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
下载之后, 设置 ~/.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
但是我碰到了, 设置还是不行 然后先查询现在的版本
/usr/libexec/java_home -V
设置版本 其实就是直接在当前命令窗口导入环境变量, 这个指标不治本, 后来自己再测了一下, 源码自己修改了 .bash_profile 文件, 但是没去导入它 (或者重新打开窗口), 这样环境变量就没有改变 =_=
export JAVA_HOME=`/usr/libexec/java_home -v 1.7.0_80`
再次, 查询, 很好, 当前环境变量已经调过来了, 然后继续执行 make -j4
java -version
bison
解决一
bison 有问题, 出现 Abort trap: 6 https://blog.csdn.net/camlot_/article/details/86540502 网站说的路径不太对, 最终自己找到的路径是 ==/opt/local/bin/bison== , 就是一开始配置环境 Macports 下载的时候, 会下到这个路径下 然而如果自己用 brew install Bison 就是在这个路径下 /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....
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
把 bison 创建一个快捷方式到某个路径下
ln -s 源文件路径 目标路径
解决二
编译 8.0 的时候查出来的
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
网上说到这个目录下, 然后更新指定 git 版本, 但是我这边根本更不了... .git 文件夹就是坏的
cd external/bison
git cherry-pick c0c852bd6fe462b148475476d9124fd740eba160
上面说的copy一个bison到这个文件夹, 也是不行的.... 后面找到了这个, 自己去编译一个 bison 出来 (上面的 git cherry-pick 就是打补丁, 而这个是手动打补丁) https://blog.csdn.net/h649305597/article/details/80322488
- 到该文件夹下
cd external/bison
- 创建 patch-high-sierra.patch
touch patch-high-sierra.patch
- 并把下面代码复制进去
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';
- 在控制台(保证当前目录是external/bison)执行 (这个是打补丁的意思??)
patch -p0 < patch-high-sierra.patch
- 返回源码根目录
cd ../..
- 编译 bison
make bison
- 复制编译好的 bison 到执行位置
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 为默认
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
然而....又报错, 说不支持, 查了一下, 说 Mojave 不支持 10.0 以下的 XCode... oh my god! 很崩溃! 退版本这个是不存在的... 好吧, 有点绝望, 各种踩坑, 这个是弄了最久的, 网上各种资料, 都无法解决.
后来再自己仔细研究了一下, 其实这些报错, 是指向 XcodeDefault.xctoolchain
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:118:42
那么是否能通过不替换XCode, 而是替换XCode下面的这个来作为一个中转方法呢??? 测试了一下, 是可以了!! (≧▽≦)/
大致就是做两步
- 下载 8.3.3 XCode
- 把 8.3.3 XCode 的 XcodeDefault.xctoolchain, 放到现在的 XCode 中, 记得, 不要删除原有的, 以后还要继续用XCode呢, 备份一下. 然后替换掉就行.
在这里插入图片描述
目前使用下来, 是没发现有什么问题 这段时间没有打开XCode过, 不知道会影响 XCode 什么问题, 建议打开XCode 之前, 先把这个改回来.
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 文件, 那么可以直接创建 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
根据提示, 执行
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 中,可同时打开的文件描述符的默认数量上限太低,在高度并行的编译流程中,可能会超出此上限。要提高此上限
# set the number of open files to be 1024
ulimit -S -n 1024
# 这个是下载 MacPorts 自动配置上去的
##
# 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.
FAILED: /bin/bash -c “(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\”-Dfile.encoding=UTF-8 -XX:+TieredCompilation\” prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 4.8.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-2.28.RELEASE.jar 2.28.RELEASE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-3.36.CANDIDATE.jar 3.36.CANDIDATE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.7.BETA.jar 4.7.BETA || exit 47 )” 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
这个问题是因为本地的curl和Jack编译工具链不兼容。
|