因为公司持续构建系统的Android SDK升级需要,不能在图形界面进行操作升级,所以搜集了以下资料,学习$ANDROID_HOME/tools/android 的命令行参数。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
ligboy@ligboy-linux:~/temp$ $ANDROID_HOME/tools/android -h Usage: android [global options] action [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. Valid actions are composed of a verb and an optional direct object: - sdk : Displays the SDK Manager window. - avd : Displays the AVD Manager window. - list : Lists existing targets or virtual devices. - list avd : Lists existing Android Virtual Devices. - list target : Lists existing targets. - list device : Lists existing devices. - list sdk : Lists remote SDK repository. - create avd : Creates a new Android Virtual Device. - move avd : Moves or renames an Android Virtual Device. - delete avd : Deletes an Android Virtual Device. - update avd : Updates an Android Virtual Device to match the folders of a new SDK. - create project : Creates a new Android project. - update project : Updates an Android project (must already have an AndroidManifest.xml). - create test-project : Creates a new Android project for a test package. - update test-project : Updates the Android project for a test package (must already have an AndroidManifest.xml). - create lib-project : Creates a new Android library project. - update lib-project : Updates an Android library project (must already have an AndroidManifest.xml). - create uitest-project: Creates a new UI test project. - update adb : Updates adb to support the USB devices declared in the SDK add-ons. - update sdk : Updates the SDK by suggesting new platforms to install if available. |
更新sdk的命令行帮助信息如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
ligboy@ligboy-linux:~/temp$ $ANDROID_HOME/tools/android update sdk --help 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-host: HTTP/HTTPS 代理Host (会覆盖默认设置) -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 : 以命令行的形式运行更新(不显示图形界面) -p --obsolete : Deprecated. Please use --all instead. -t --filter : 限制更新的包的类型,多个值以逗号分割的list,类型有 [platform, system-image, tool, platform-tool, doc, sample,source]. 也可以指定'list sdk --extended'展示的包的标识 -n --dry-mode : Simulates the update but does not download or install anything. |
屏蔽掉images、source、sample等构建无用的模块
android -s update sdk -u -t "extra-android-support,extra-google-m2repository,extra-google-google_play_services,extra-android-m2repository,platform-tools,tool,platform"
其实升级的最大问题就是万恶GFW的阻挠问题,也就是设置代理问题。对于android sdk的更新的代理设置有多种方式.
一种是在 ~/.android/.androidtool.cfg 中指定,如果之前没有运行过sdk manager,该文件可能不存在,自己创建即可。文件的内容如下:
1 2 3 4 5 6 7 8 9 |
### Settings for Android Tool #Tue Mar 10 08:36:19 CST 2015 http.proxyHost=proxy.example.com http.proxyPort=8080 sdkman.enable.previews=false sdkman.ask.adb.restart=false sdkman.show.update.only=true sdkman.force.http=true sdkman.use.dl.cache=true |
另外一种是实在更新命令中指定代理参数:
$ANDROID_HOME/tools/android update sdk --proxy-port proxy.example.com --proxy-port 8080 -s -u -t "1"