Android R上curl和wget等无法使用的解决办法

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、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值