パッケージのバージョン 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 までのパッケージを含めます。たとえば、カナリア チャネルを指定して、すべてのチャネルからパッケージを一覧表示します。
パッケージをインストールします。
sdkmanager packages [options]
引数は、packages
引用符で囲まれた SDK スタイルのパスです (たとえば、"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.