版本 25.2.3(及更高版本)的Android SDK Tools
软件包包含新工具 - sdkmanager - 它简化了从命令行安装构建工具的任务。
它位于android_sdk/tools/bin
文件夹中。
用法(来自文档):
列出已安装和可用的软件包:
sdkmanager --list [options] \
[--channel=channel_id] // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary)
使用 channel 选项来包含一个包,从一个通道直到包含 channel_id。例如,指定 canary 频道以列出来自所有频道的包。
安装包:
sdkmanager packages [options]
参数是 SDK 样式的packages
路径,用引号括起来(例如,"build-tools;25.0.0"
或"platforms;android-25"
)。您可以传递多个包路径,以空格分隔,但它们必须各自用自己的一组引号括起来。
示例用法(在我的 Mac 上):
alex@mbpro:~/sdk/tools/bin$ ls ../../build-tools/
25.0.0/
alex@mbpro:~/sdk/tools/bin$ ./sdkmanager "build-tools;25.0.2"
done
alex@mbpro:~/sdk/tools/bin$ ls ../../build-tools/
25.0.0/ 25.0.2/
您还可以指定各种选项,例如强制所有连接使用 HTTP ( --no_https
),或者为了使用代理服务器 (--proxy_host=address
和--proxy_port=port
)。
要检查可用选项,请使用--help
标志。在我的机器(Mac)上,输出如下:
alex@mbpro:~/sdk/tools/bin$ ./sdkmanager --help
Usage:
sdkmanager [--uninstall] [<common args>] \
[--package_file <package-file>] [<packages>...]
sdkmanager --update [<common args>]
sdkmanager --list [<common args>]
In its first form, installs, or uninstalls, or updates packages.
<package> is a sdk-style path (e.g. "build-tools;23.0.0" or
"platforms;android-23").
<package-file> is a text file where each line is a sdk-style path
of a package to install or uninstall.
Multiple --package_file arguments may be specified in combination
with explicit paths.
In its second form (with --update), currently installed packages are
updated to the latest version.
In its third form, all installed and available packages are printed out.
Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
--channel=<channelId>: Include packages in channels up to <channelId>.
Common channels are:
0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).
--include_obsolete: With --list, show obsolete packages in the
package listing. With --update, update obsolete
packages as well as non-obsolete.
--no_https: Force all connections to use http rather than https.
--proxy=<http | socks>: Connect via a proxy of the given type.
--proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.
--proxy_port=<port #>: Proxy port to connect to.
* If the env var REPO_OS_OVERRIDE is set to "windows",
"macosx", or "linux", packages will be downloaded for that OS.