1. 程式人生 > >linux下通過命令列更新android sdk

linux下通過命令列更新android sdk

/usr/share/android/android-sdk-linux/android

$ android update sdk --no-ui

android provide these options for automatic updates:

Action"update sdk":Updates the SDK by suggesting new platforms to install if available.Options:-f --force    Forces replacement of a packageor its parts, even if something has been modified
  
-u --no-ui Updatesfrom command-line (does not display the GUI)-o --obsolete Installs obsolete packages -t --filter A filter that limits the update to the specified types of packages in the form of a comma-separated list of [platform, tool, platform-tool, doc, sample, extra]-s
--no-https Uses HTTP instead of HTTPS (the default)for downloads -n --dry-mode Simulates the update but does not download or install anything

If you want to list which packages are available for installation you can use

$ android list sdk

and you'll obtain an ordered list of packages, for example

Packages available for installation or update:91- ARM EABI v7a SystemImage,Android API 15, revision 22-Intel x86 AtomSystemImage,Android API 15, revision 13-AndroidSupport, revision 84-GoogleAdMobAds SDK, revision 65-GoogleAnalytics SDK, revision 26-GooglePlay APK ExpansionLibrary, revision 17-GooglePlayBillingLibrary, revision 28-GooglePlayLicensingLibrary, revision 29-GoogleWebDriver, revision 2

Also you can limit the update only to a desired component if you use the --filter option

$ android update sdk --filter <component>--no-ui

where component is one or more of

  • the numbers returned by android list sdk (i.e. 1, also know as package index)
  • add-on
  • doc
  • extra
  • platform
  • platform-tool
  • sample
  • source
  • system-image
  • tool

or can be one or more specific identifiers. For instance, if you just want to download a small set of specific packages, you could do this:

$ android update sdk -u --filter platform-tools,android-16,extra-android-support

and you'll just get the platform tools, api level 16 and support package jar. This is really handy if you're building a build machine only and would have to pay for downloading all the extra stuff that you'll never use.

To see the available options you can use --help, for example

$ android --help list sdk

       Usage:
       android [global options] list 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"list sdk":Lists remote SDK repository.Options:-o --obsolete  :Deprecated.Pleaseuse--all instead.-a --all       :Lists all available packages (including obsolete and
                   installed ones)--proxy-host: HTTP/HTTPS proxy host (overrides settings ifdefined)--proxy-port: HTTP/HTTPS proxy port (overrides settings ifdefined)-s --no-https  :Uses HTTP instead of HTTPS (the default)for downloads.-e --extended  :Displays extended details on each package-u --no-ui     :Displays list result on console (no GUI)[Default:true]

i use this to install and update the sdk on travis-ci

curl --location http://dl.google.com/android/android-sdk_r22.3-linux.tgz | tar -x -z -C $HOMEexport ANDROID_HOME=$HOME/android-sdk-linux
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
( sleep 5&&while[1];do sleep 1; echo y;done)| android update sdk --no-ui --filter platform-tool,android-19,sysimg-19,build-tools-19.0.1