用命令行方式升级Android SDK

为什么用命令行?因为google站点国内很难访问,用Android SDK Manager下载很麻烦。但是我有美国的服务器,用命令行可以升级SDK,然后复制下来。

1. 安装java

Ubuntu 13.10 安装Oralce JDK

2. 下载Android SDK

wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz 

解压后,进入目录的tools目录,执行:

root@localhost:/opt/android-sdk-linux/tools# ./android list sdk
Refresh Sources:
  Fetching https://dl-ssl.google.com/android/repository/addons_list-2.xml
  Validate XML
  Parse XML
  Fetched Add-ons List successfully
  Refresh Sources
  Fetching URL: https://dl-ssl.google.com/android/repository/repository-10.xml
  Validate XML: https://dl-ssl.google.com/android/repository/repository-10.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/repository-10.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/addon.xml
  Validate XML: https://dl-ssl.google.com/android/repository/addon.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/addon.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/addon-6.xml
  Validate XML: https://dl-ssl.google.com/android/repository/addon-6.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/addon-6.xml
  Fetching URL: https://dl-ssl.google.com/glass/gdk/addon.xml
  Validate XML: https://dl-ssl.google.com/glass/gdk/addon.xml
  Parse XML:    https://dl-ssl.google.com/glass/gdk/addon.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/extras/intel/addon.xml
  Validate XML: https://dl-ssl.google.com/android/repository/extras/intel/addon.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/extras/intel/addon.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/sys-img/android/sys-img.xml
  Validate XML: https://dl-ssl.google.com/android/repository/sys-img/android/sys-img.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/sys-img/android/sys-img.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/sys-img/android-wear/sys-img.xml
  Validate XML: https://dl-ssl.google.com/android/repository/sys-img/android-wear/sys-img.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/sys-img/android-wear/sys-img.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/sys-img/android-tv/sys-img.xml
  Validate XML: https://dl-ssl.google.com/android/repository/sys-img/android-tv/sys-img.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/sys-img/android-tv/sys-img.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/sys-img/google_apis/sys-img.xml
  Validate XML: https://dl-ssl.google.com/android/repository/sys-img/google_apis/sys-img.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/sys-img/google_apis/sys-img.xml
  Fetching URL: https://dl-ssl.google.com/android/repository/sys-img/x86/addon-x86.xml
  Validate XML: https://dl-ssl.google.com/android/repository/sys-img/x86/addon-x86.xml
  Parse XML:    https://dl-ssl.google.com/android/repository/sys-img/x86/addon-x86.xml
Packages available for installation or update: 66
   1- Android SDK Tools, revision 23.0.5
   2- Android SDK Platform-tools, revision 21
   3- Android SDK Build-tools, revision 21.1.1
   4- Documentation for Android SDK, API 21, revision 1
   5- SDK Platform Android 5.0, API 21, revision 1
   6- SDK Platform Android 4.4W.2, API 20, revision 2
   7- SDK Platform Android 4.4.2, API 19, revision 4
   8- SDK Platform Android 4.3.1, API 18, revision 3
   9- SDK Platform Android 4.2.2, API 17, revision 3
  10- SDK Platform Android 4.1.2, API 16, revision 5
  11- SDK Platform Android 4.0.3, API 15, revision 5
  12- SDK Platform Android 4.0, API 14, revision 4
  13- SDK Platform Android 3.2, API 13, revision 1
  14- SDK Platform Android 3.1, API 12, revision 3
  15- SDK Platform Android 3.0, API 11, revision 2
  16- SDK Platform Android 2.3.3, API 10, revision 2
  17- SDK Platform Android 2.2, API 8, revision 3
  18- SDK Platform Android 2.1, API 7, revision 3
  19- SDK Platform Android 1.6, API 4, revision 3
  20- SDK Platform Android 1.5, API 3, revision 4
  21- Samples for SDK API 21, revision 3
  22- Samples for SDK API 20, revision 3
  23- Samples for SDK API 19, revision 6
  24- Samples for SDK API 18, revision 1
  25- Samples for SDK API 17, revision 1
  26- Samples for SDK API 16, revision 1
  27- Samples for SDK API 15, revision 2
  28- Samples for SDK API 14, revision 2
  29- Samples for SDK API 13, revision 1
  30- Samples for SDK API 12, revision 1
  31- Samples for SDK API 11, revision 1
  32- Samples for SDK API 10, revision 1
  33- Samples for SDK API 8, revision 1
  34- Samples for SDK API 7, revision 1
  35- Google APIs ARM EABI v7a System Image, Google Inc. API 21, revision 2
  36- Google APIs Intel x86 Atom_64 System Image, Google Inc. API 21, revision 2
  37- Google APIs Intel x86 Atom System Image, Google Inc. API 21, revision 2
  38- Google APIs, Android API 21, revision 1
  39- Google APIs (x86 System Image), Android API 19, revision 9
  40- Google APIs (ARM System Image), Android API 19, revision 9
  41- Glass Development Kit Preview, Android API 19, revision 11
  42- Google APIs, Android API 18, revision 3
  43- Google APIs, Android API 17, revision 3
  44- Google APIs, Android API 16, revision 3
  45- Google APIs, Android API 15, revision 2
  46- Google APIs, Android API 14, revision 2
  47- Google APIs, Android API 13, revision 1
  48- Google TV Addon, Android API 13, revision 1
  49- Google APIs, Android API 12, revision 1
  50- Google TV Addon, Android API 12, revision 2
  51- Google APIs, Android API 11, revision 1
  52- Google APIs, Android API 10, revision 2
  53- Google APIs, Android API 8, revision 2
  54- Google APIs, Android API 7, revision 1
  55- Google APIs, Android API 4, revision 2
  56- Google APIs, Android API 3, revision 3
  57- Android Support Repository, revision 9
  58- Android Support Library, revision 21.0.2
  59- Google Play services for Froyo, revision 12
  60- Google Play services, revision 21
  61- Google Repository, revision 13
  62- Google Play APK Expansion Library, revision 3
  63- Google Play Billing Library, revision 5
  64- Google Play Licensing Library, revision 2
  65- Android Auto API Simulators, revision 1
  66- Google Web Driver, revision 2


好快啊,现在选择想要的安装吧。

这时候可能会遇到adb找不到文件的错误,安装下面两个包:

apt-get install lib32stdc++6
apt-get install lib32z1
 

可以安装了,用下面的命令:

./android update sdk --no-ui --filter 2

也可以不加--filter参数,全部下载,我运行了两次,得到了总大小6.3GB的目录。


然后复制到自己的电脑上吧。


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。