Android SDK Installation, Configuration and ADB Usage Guide
The Android SDK ships with the ADB (Android Debug Bridge) tool by default.
Download Links
- Domestic mirror download: http://tools.android-studio.org/index.php/sdk/
- Official Google China download: https://developer.android.google.cn/studio/

After downloading, extract the archive to a dedicated directory on your computer, then run SDK Manager.exe to launch the SDK management tool.

If SDK Manager.exe crashes immediately on launch, first confirm that you have JDK installed and configured correctly on your system, and that you have set up the ANDROID_HOME environment variable beforehand.
Environment Variable Configuration
Step 1: Configure ANDROID_HOME
Create a new system environment varible named ANDROID_HOME, set its value to the root path of your extracted Android SDK, for example D:\android-sdk-windows.

Step 2: Update PATH Variable
Edit the system PATH environment variable, add the full paths of the platform-tools and tools folders under your SDK root directory to the PATH list.

Verify Installation
Press Win + R to open the Run dialog, enter cmd to launch the Windows Command Prompt. Type adb in the command line and press Enter. If you see ADB command usage output as shown below, the installation and configuration are successful.

Common ADB Commands
You can find the full official ADB command documentation on the Android Developer website for more advanced usage.
All lines starting with # in the code blocks below are explanatory comments.
1. List Connected Devices
# List all connected Android devices/emulators with detailed information
adb devices -l

Common Connection Troubleshooting
If your device does not appear in the list:
- Make sure Developer Options and USB Debugging are enabled on your Android device
- Confirm that the correct USB driver for your device is installed on your PC
- Check if the default ADB port 5037 is occupied by another process
- Temporarily disable third-party antivirus software that may block ADB connecsions
- Replace your USB cable if its damaged
2. Access Device Shell
Android is based on the Linux kernel, so you can use standard Linux shell commands after entering the device shell.
# Enter shell of the connected device
# Prompt # = root access, $ = normal user access
adb shell
# Specify target device when multiple devices are connected
adb -s emulator-5554 shell
# Exit shell and return to local command line
exit
3. Install APK
Run these commands in your local command line (not inside the ADB shell):
# Install APK, you can drag and drop the APK file into the command line to auto-fill the path
adb install ./demo-release.apk
# Overwrite existing installed version of the same app
adb install -r ./demo-release.apk
# Install APK to a specified connected device
adb -s emulator-5554 install -r ./demo-release.apk
4. Uninstall App
# Uninstall app completely, remove all data
adb uninstall com.example.demoapp
# Uninstall app but keep user data and cache files
adb uninstall -k com.example.demoapp
5. List Installed App Packages
# List all installed app packages on the device
adb shell pm list packages
# Filter packages by keyword (use findstr instead of grep on Windows)
adb shell pm list packages | grep "demo"
6. File Transfer Between PC and Device
# Push file from local PC to device
adb push ./local_document.pdf /sdcard/Documents/
# Pull file from device to local PC
# Note: Do not pull directly to the root of a system drive on Windows to avoid permission errors
adb pull /sdcard/Documents/device_photo.png C:\Users\YourName\Pictures\
7. Take Device Screenshot
# Capture screenshot and save it to the device's internal storage
adb shell screencap /sdcard/temp_screenshot.png
# Pull the captured screenshot to your local desktop
adb pull /sdcard/temp_screenshot.png C:\Users\YourName\Desktop\
8. Manage ADB Service
# Stop running ADB service
adb kill-server
# Start ADB service
adb start-server
Fix ADB Port 5037 Occupied Error
If you get a port occupied error on Windows, use the following commands to release the port:
# Find the PID of the process using port 5037
netstat -ano | findstr "5037"
# Sample output: TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 4792
# Kill the process with the corresponding PID
taskkill -f -pid 4792
9. Get APK Metadata with AAPT
The AAPT tool is included with the Android SDK, you can use it to read detailed information about an APK file:
# Get full metadata of an APK file
aapt dump badging ./demo-release.apk
# Extract the launchable activity name of the APK (used for app launch automation)
aapt dump badging ./demo-release.apk | findstr "launchable-activity"