コマンドライン ツール
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android SDK は、アプリ開発に必須のさまざまなパッケージで構成されています。
このページでは、利用可能な最重要コマンドライン ツールのリストを、配布パッケージごとに示します。
Android Studio の SDK Manager または sdkmanager
コマンドライン ツールを使用して、各パッケージのインストールや更新を行うことができます。パッケージはすべて、Android SDK ディレクトリにダウンロードされます。Android SDK ディレクトリの場所を確認する手順は次のとおりです。
- Android Studio で、[File] > [Project Structure] をクリックします。
- 左パネルで、[SDK Location] を選択します。
[Android SDK location] の下にパスが表示されます。
環境変数を設定する
コマンドラインを使用する場合は、ANDROID_HOME
の環境変数を設定することをおすすめします。また、コマンド検索パスに ANDROID_HOME/tools
、ANDROID_HOME/tools/bin
、ANDROID_HOME/platform-tools
を含めるように設定すると、一般的なツールを見つけることができます。手順は OS によって異なりますが、一般的なガイダンスについては環境変数を設定する方法をご覧ください。
場所: android_sdk/cmdline-tools/version/bin/
注: cmdline-tools
の Android SDK コマンドライン ツール パッケージは、tools
の SDK Tools パッケージに代わるものです。新しいパッケージでは、コマンドライン ツールのバージョンを選択してインストールすることができ、複数のバージョンをまとめてインストールすることもできます。古いパッケージでは、インストールできるのはツールの最新バージョンのみです。そのため、新しいパッケージを使用すると、新しいバージョンがリリースされた場合でもコードの動作を継続しつつ、コマンドライン ツールの特定のバージョンを使用できます。サポートが終了した SDK Tools パッケージについては、SDK Tools リリースノートをご覧ください。
Android Studio を使用していない場合は、こちらからコマンドライン ツール パッケージをダウンロードできます。
apkanalyzer
- ビルドプロセスの完了後に APK の構成に関する分析情報を確認できます。
avdmanager
- コマンドラインから Android Virtual Device(AVD)を作成、管理できます。
lint
- コードをスキャンして、コードの構造品質に関する問題を検出し、修正します。
retrace
- R8 でコンパイルされたアプリの場合、
retrace
は、元のソースコードにマッピングされる難読化されたスタック トレースをデコードします。
sdkmanager
- Android SDK のパッケージを表示、インストール、更新、アンインストールできます。
場所: android_sdk/build-tools/version/
詳しくは、SDK Build Tools リリースノートをご覧ください。
このパッケージは、Android アプリをビルドする際に必須です。パッケージ内のツールのほとんどは、ビルドツールによって呼び出されるものであり、デベロッパーが明示的に使用するものではありません。ただし、以下のコマンドライン ツールは、場合によっては役に立つことがあります。
AAPT2
- Android リソースを解析し、インデックスを付けて、Android プラットフォーム向けに最適化されたバイナリ形式にコンパイルし、コンパイルしたリソースを 1 つの出力にパッケージ化します。
apksigner
- APK に署名し、その APK がサポートするすべてのプラットフォーム バージョンで APK 署名が正常に検証されるかどうかをチェックします。
zipalign
- すべての非圧縮データの先頭を基準とした特定のアライメントで開始するように、APK ファイルを最適化します。
注: 複数のバージョンのビルドツールを使用して、Android バージョン別のアプリをビルドできます。
場所: android_sdk/platform-tools/
詳細については、SDK Platform Tools リリースノートをご覧ください。
これらのツールは、Android プラットフォームの最新バージョンごとに更新され、新しい機能のサポートと、ツールの修正や改善が行われます。各アップデートには、以前のバージョンのプラットフォームとの下位互換性があります。
SDK Platform Tools は、SDK Manager からダウンロードできます。また、こちらからもダウンロードできます。
adb
- Android Debug Bridge(adb)は、エミュレータ インスタンスや Android デバイスの状態を管理できる多用途ツールです。また、このツールを使用して、デバイスに APK をインストールすることもできます。
etc1tool
- PNG 画像を ETC1 圧縮標準にエンコードし、ETC1 圧縮画像をデコードして PNG に戻すことができるコマンドライン ユーティリティです。
fastboot
- プラットフォームや各種システムのイメージをデバイスにフラッシュします。フラッシュの手順については、Nexus デバイスおよび Pixel デバイスのファクトリー イメージをご覧ください。
logcat
- adb 経由で呼び出され、アプリログやシステムログを表示します。
場所: android_sdk/emulator/
詳しくは、Android Emulator リリースノートをご覧ください。
このパッケージは、Android Emulator を使用する場合に必須です。次のツールが含まれています。
emulator
- 実際の Android ランタイム環境でのアプリのデバッグとテストに使用できる、QEMU ベースのデバイス エミュレーション ツールです。
mksdcard
- エミュレータで使用するディスク イメージを作成して、SD カードなどの外部ストレージ カードの有無をシミュレートできます。
注: リビジョン 25.3.0 より前のエミュレータ ツールは、SDK Tools パッケージに含まれていました。
Jetifier
Jetifier は、サポート ライブラリのクラスを使用するライブラリを読み取り、新しい AndroidX のクラスを使用する同等のライブラリを出力します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2023-12-02 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2023-12-02 UTC。"],[],[],null,["# Command-line tools\n\nThe Android SDK is composed of multiple packages that are required for app development.\nThis page lists the most important command-line tools that are\navailable, organized by the packages in which they're delivered.\n\nYou can install and update each package using\nAndroid Studio's [SDK Manager](/studio/intro/update#sdk-manager)\nor the [`sdkmanager`](/studio/command-line/sdkmanager)\ncommand-line tool.\nAll of the packages are downloaded into your Android SDK directory, which\nyou can locate as follows:\n\n1. In Android Studio, click **File \\\u003e Project Structure**.\n2. Select **SDK Location** in the left pane. The path is shown under **Android SDK location**.\n\n### Set environment variables\n\nWe recommend setting the environment variable for\n[\u003cvar translate=\"no\"\u003eANDROID_HOME\u003c/var\u003e](/studio/command-line/variables#envar) when using\nthe command line. Also, set your command search path to include\n\u003cvar translate=\"no\"\u003eANDROID_HOME/tools\u003c/var\u003e, \u003cvar translate=\"no\"\u003eANDROID_HOME/tools/bin\u003c/var\u003e, and\n\u003cvar translate=\"no\"\u003eANDROID_HOME/platform-tools\u003c/var\u003e to find the most common tools. The steps\nvary depending on your OS, but read\n[How to set environment variables](/studio/command-line/variables#set) for general guidance.\n\nAndroid SDK Command-Line Tools\n------------------------------\n\n\nLocated in: \u003cvar translate=\"no\"\u003eandroid_sdk\u003c/var\u003e`/cmdline-tools/`\u003cvar translate=\"no\"\u003eversion\u003c/var\u003e`/bin/` \n\nNote: The Android SDK Command-Line Tools package, located in\n`cmdline-tools`, replaces the SDK Tools package, located in `tools`. With\nthe new package, you can select the version of the command line tools you want to install,\nand you can install multiple versions at a time. With the old package, you can only install the\nlatest version of the tools. Thus, the new package lets you depend on specific versions of the\ncommand-line tools without having your code break when new versions are released. For information\nabout the deprecated SDK Tools package, see the\n[SDK Tools release notes](/studio/releases/sdk-tools).\n\nIf you are not using Android Studio, you can download the command-line tools package\n[here](/studio#command-tools).\n\n[apkanalyzer](/studio/command-line/apkanalyzer)\n: Provides insight into the composition of your APK after the build process completes.\n\n[avdmanager](/studio/command-line/avdmanager)\n: Lets you create and manage Android Virtual Devices (AVDs)\n from the command line.\n\n[lint](/studio/write/lint#commandline)\n: Scans code to help you identify and correct problems\n with the structural quality of your code.\n\n[`retrace`](/studio/command-line/retrace)\n: For applications compiled by R8, `retrace` decodes an obfuscated stack trace that\n maps back to your original source code.\n\n[sdkmanager](/studio/command-line/sdkmanager)\n: Lets you view, install, update, and uninstall packages for the Android SDK\n\nAndroid SDK Build Tools\n-----------------------\n\n\nLocated in: \u003cvar translate=\"no\"\u003eandroid_sdk\u003c/var\u003e`/build-tools/`\u003cvar translate=\"no\"\u003eversion\u003c/var\u003e`/` \n\nSee [SDK Build Tools release notes](/studio/releases/build-tools) for more\ninformation.\n\nThis package is required to build Android apps. Most of the tools in this package are\ninvoked by the build tools and not intended for you. However, the following\ncommand-line tools might be useful:\n\n[`AAPT2`](/studio/command-line/aapt2)\n: Parses, indexes, and compiles Android resources into a binary format that\n is optimized for the Android platform and packages the compiled resources\n into a single output.\n\n[`apksigner`](/studio/command-line/apksigner)\n: Signs APKs and checks whether APK signatures will be verified\n successfully on all platform versions that a given APK supports.\n\n[`zipalign`](/studio/command-line/zipalign)\n: Optimizes APK files by ensuring that all uncompressed data starts with\n a particular alignment relative to the start of the file.\n\n**Note:** You can have multiple versions of the build tools\nto build your app for different Android versions.\n\nAndroid SDK Platform Tools\n--------------------------\n\n\nLocated in: \u003cvar translate=\"no\"\u003eandroid_sdk\u003c/var\u003e`/platform-tools/` \n\nSee [SDK Platform Tools release notes](/studio/releases/platform-tools) for more\ninformation.\n\nThese tools are updated for every new version of the Android platform to support new features\nand fix or improve the tools, and each update\nis backward compatible with earlier platform versions.\n\nIn addition to downloading from the SDK Manager, you can download the SDK Platform Tools\n[here](/studio/releases/platform-tools#downloads.html).\n\n[`adb`](/studio/command-line/adb)\n: Android Debug Bridge (adb) is a versatile tool that lets you manage the state of an\n emulator instance or Android-powered device. You can also use it to install an APK on a\n device.\n\n[`etc1tool`](/studio/command-line/etc1tool)\n: A command-line utility that lets you encode PNG images to the ETC1\n compression standard and decode ETC1 compressed images back to PNG.\n\n`fastboot`\n: Flashes a device with platform and other system images. For flashing instructions,\n see [Factory Images for Nexus and\n Pixel Devices](https://developers.google.com/android/images).\n\n[`logcat`](/studio/command-line/logcat)\n: Invoked by adb to view app and system logs.\n\nAndroid Emulator\n----------------\n\n\nLocated in: \u003cvar translate=\"no\"\u003eandroid_sdk\u003c/var\u003e`/emulator/` \n\nSee [Android Emulator release notes](/studio/releases/emulator) for more\ninformation.\n\nThis package is required to use the Android Emulator. It includes the following:\n\n[emulator](/studio/run/emulator-commandline)\n: A QEMU-based device-emulation tool that you can use to debug and test\n your applications in an actual Android run-time environment.\n\n[mksdcard](/studio/command-line/mksdcard)\n: Helps you create a disk image that you can use with the emulator\n to simulate the presence of an external storage card, such as an SD card.\n\n**Note:** Prior to revision 25.3.0, the emulator tools were included with the\nSDK Tools package.\n\nJetifier\n--------\n\n[Jetifier](/studio/command-line/jetifier) reads a library that uses\nSupport Library classes and outputs an equivalent library that uses the newer\nAndroidX classes."]]