命令行更新 android sdk

不习惯 ubuntu 界面,只安装了 ubuntu server 版本。

下载并解压好android sdk,如何更新呢? 就是在命令行使用 android 程序。

/opt/android-sdk-linux/tools$ ./android update sdk help
Error: Argument 'help' is not recognized.

       Usage:
       android [global options] update sdk [action options]
       Global options:
  -h --help       : Help on a specific command.
  -v --verbose    : Verbose mode, shows errors, warnings and all messages.
     --clear-cache: Clear the SDK Manager repository manifest cache.
  -s --silent     : Silent mode, shows errors only.

                     Action "update sdk":
  Updates the SDK by suggesting new platforms to install if available.
Options:
     --proxy-port: HTTP/HTTPS proxy port (overrides settings if defined)
     --proxy-host: HTTP/HTTPS proxy host (overrides settings if defined)
  -s --no-https  : Uses HTTP instead of HTTPS (the default) for downloads.
  -a --all       : Includes all packages (such as obsolete and non-dependent
                   ones.)
  -f --force     : Forces replacement of a package or its parts, even if
                   something has been modified.
  -u --no-ui     : Updates from command-line (does not display the GUI)
  -p --obsolete  : Deprecated. Please use --all instead.
  -t --filter    : A filter that limits the update to the specified types of
                   packages in the form of a comma-separated list of
                   [platform, system-image, tool, platform-tool, doc, sample,
                   source]. This also accepts the identifiers returned by
                   'list sdk --extended'.
 -n --dry-mode  : Simulates the update but does not download or install
                   anything.
好了,可以使用命令行更新了,
$ ./android update sdk -u -t platform,platform-tool
$ ./android update sdk -u -t build-tools-20.0.0

使用如下代理服务器:

大连东软信息学院镜像服务器地址:

http://mirrors.neusoft.edu.cn 端口:80

北京化工大学镜像服务器地址:

IPv4: http://ubuntu.buct.edu.cn/ 端口:80
IPv4: http://ubuntu.buct.cn/ 端口:80
IPv6: http://ubuntu.buct6.edu.cn/ 端口:80

上海GDG镜像服务器地址:

http://sdk.gdgshanghai.com 端口:8000

想查看列表
/opt/android-sdk-linux/tools$ ./android list sdk --proxy-host sdk.gdgshanghai.com --proxy-port 8000 -s
Packages available for installation or update: 46
   1- Android SDK Tools, revision 24.4.1
   2- Android SDK Platform-tools, revision 23.0.1
   3- Android SDK Build-tools, revision 23.0.2
   4- Documentation for Android SDK, API 23, revision 1
   5- SDK Platform Android 6.0, API 23, revision 1
   6- SDK Platform Android 5.1.1, API 22, revision 2
   7- SDK Platform Android 5.0.1, API 21, revision 2
   8- SDK Platform Android 4.4W.2, API 20, revision 2
   9- SDK Platform Android 4.4.2, API 19, revision 4
  10- SDK Platform Android 4.3.1, API 18, revision 3
  11- SDK Platform Android 4.2.2, API 17, revision 3
  12- SDK Platform Android 4.1.2, API 16, revision 5
  13- SDK Platform Android 4.0.3, API 15, revision 5
  14- SDK Platform Android 2.3.3, API 10, revision 2
  15- SDK Platform Android 2.2, API 8, revision 3
  16- Samples for SDK API 23, revision 2
  17- Samples for SDK API 22, revision 6
。。。。。。

开始获取列表:
/opt/android-sdk-linux/tools$ ./android update sdk --proxy-host sdk.gdgshanghai.com --proxy-port 8000 -s -u -t platform, platform-tool
然后就可以更新了。
如果发现更新后总是提示 There is nothing to install or update.
则返回到上一级目录,删除 temp 文件夹,然后再进入tools目录执行上面命令。
如果还不行,检查 home 目录的.android目录权限是否可写。
如果还不行,再检查代理服务器端口和地址,以及是否使用了 -s 参数强制用 http。

android 程序遇到以上错误不会提示错误,只是提示There is nothing to install or update.
比如网络代理不通也做如此提示,真是坑。

查看其他可以获取的内容:
/opt/android-sdk-linux/tools$ ./android list sdk --proxy-host sdk.gdgshanghai.com --proxy-port 8000 -s --extended
会显示如下内容:
----------
id: 34 or "extra-android-m2repository"
     Type: Extra
     Desc: Android Support Repository, revision 24
           By Android
           Local Maven repository for Support Libraries
           Install path: extras/android/m2repository
----------
id: 35 or "extra-android-support"
     Type: Extra
     Desc: Android Support Library, revision 23.1
           By Android
           Install path: extras/android/support
然后再使用 update sdk 取下来,比如去 extra-android-support 就输入如下内容:
/opt/android-sdk-linux/tools$ ./android update sdk --proxy-host sdk.gdgshanghai.com --proxy-port 8000 -s -u -t extra-android-support
或者输入
/opt/android-sdk-linux/tools$ ./android update sdk --proxy-host sdk.gdgshanghai.com --proxy-port 8000 -s -u -t 35
即可。





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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值