I. Introduction
We continue to summarize our learning
basics, warming up to the past.
This article briefly introduces Android command line tools.
2. Outline
The Android SDK contains several packages needed to develop applications. This page lists the most important command line tools available (organized by the packages that provide them).
Each package can be installed and updated using Android Studio’s SDK manager or the sdkmanager command line tool.
All packages are downloaded to the Android SDK directory, which you can find as follows:
- In Android Studio, click File > Project Structure.
- In the left pane, select SDK Location. the path is displayed under Android SDK location.
- Setting environment variables
We recommend that you set the environment variable for ANDROID_HOME when using the command line.
In addition, set the command search path to include ANDROID_HOME/tools, ANDROID_HOME/tools/bin and ANDROID_HOME/platform-tools.
Find the most common tools. The exact steps vary depending on the operating system used, but for general guidance, see How to set environment variables.
https://developer.
android.google.cn/studio/command-line?hl=zh-cn#tools-sdk
III. Relevant tools
3.1 Android SDK Command Line Tools
Location: android_sdk/cmdline-tools/version/bin/
Note: The Android SDK command line tools package (located at cmdline-tools) replaces the SDK tools package (located at tools).
When using a new package, you can select the version of the command line tool you want to install, and you can also install more than one version at a time. When using the old package, you can only install the latest version of the tool.
As a result, the new package allows you to rely on a specific version of the command line tools when releasing a new version without causing code breaks. For information about deprecated SDK Tools packages, see the SDK Tools Release Notes.
If you don’t use Android Studio, you can download the Command Line Tools package here.
- apkanalyzer
For in-depth analysis of your APK composition after the build process is complete.
- avdmanager
For creating and managing Android Virtual Devices (AVDs) from the command line.
- lint
Used to scan code, it can help you identify and correct problems with the quality of code structure.
- retrace
For applications compiled by R8, trace decodes the obfuscated stack trace, which is mapped back to your original source code.
- sdkmanager
Package for viewing, installing, updating, and uninstalling the Android SDK.
3.2 Android SDK build tools
Located at: android_sdk/build-tools/version/
For more information, see SDKs
Build Tool Release Notes。
This package is necessary to build Android applications. Most of the tools in this package are called by the build tool, not for your use. However, the following command line tools may be useful:
- AAPT2
Parses Android resources, indexes them, compiles them into a binary format optimized for the Android platform, and finally packages the compiled resources into a single output.
- apksigner
Sign the APK and check if the signature can be successfully verified on all platform versions supported by the given APK.
- zipalign
Optimize APK files by ensuring that the beginning of all uncompressed data is specifically aligned with respect to the beginning of the file.
3.3 Android SDK Platform Tools
Located at: android_sdk/platform-tools/
For more information, see SDKs
Platform Tools Release Notes。
As each new version of the Android platform is released, the tools are updated accordingly to support new features, fix problems with the tools, or improve the tools, and each update is backward compatible with earlier platform versions.
In addition to downloading from the SDK Manager, you can also download the SDK in the
Download the SDK platform tools here。
- adb
The Android Debug Bridge (adb) is a versatile tool that you can use to manage the status of an emulator instance or an Android device. You can also use it to install APKs on devices.
- etc1tool
A command line utility that you can use to encode PNG images into the ETC1 compression standard format and decode ETC1 compressed images back into PNG.
- fastboot
Flush a platform or other system image to your device. For flashing instructions, see Factory Images for Nexus and Pixel Devices.
- logcat
Can be invoked via adb for viewing application and system logs.
3.4 Android Emulator
Located at: android_sdk/emulator/
For more information, see
Android emulator version description。
This package is required to use the Android emulator. This package contains the following tools:
- emulator
QEMU-based device emulation tool for debugging and testing applications in a real Android runtime environment.
- mksdcard
Helps you create disk images that can be used with the emulator to simulate the presence of an external memory card, such as an SD card.