1.问题
sh脚本文件中使用到了curl和wget,在编译的时候出现了异常:
11:00:44 Disallowed PATH tool "curl" used: xxx ... ...
11:00:44 See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.
...
11:00:44 Disallowed PATH tool "wget" used: xxx ... ...
11:00:44 See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.
...
"curl" is not allowed to be used. See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.
"wget" is not allowed to be used. See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.
2.原因
Android Q 版本的限制:
3.解决
在build/soong/ui/build/paths/config.go中把需要用到的curl、wget等命令加入白名单:
var Configuration = map[string]PathConfig{
"bash": Allowed,
"dd": Allowed,
....
"unzip": Allowed,
"zip": Allowed,
"curl": Allowed, // add
"wget": Allowed, // add
....
}
加上这个白名单后,还是会报异常:
wget: missing URL
Usage: wget [OPTION]... [URL]...
还需要在BoardConfig.mk中加上:
BUILD_BROKEN_USES_NETWORK := true
TEMPORARY_DISABLE_PATH_RESTRICTIONS := true
PS.wget是一款免费的工具,用于从网上自动下载文件,它在带宽非常窄,网络不稳定的情况下,具有很强的适应性。
curl命令是一个功能强大的网络工具,它能够通过http、ftp等方式下载文件,也能够上传文件,同时支持HTTPS等众多协议,
还支持POST、cookies、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。