Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Android SDK Installation, Configuration and ADB Usage Guide

Tech 2

The Android SDK ships with the ADB (Android Debug Bridge) tool by default.

Download Links

![](SDK download page screenshot)

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

![](SDK Manager launch interface)

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.

![](ANDROID_HOME environment variable configuration screenshot)

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.

![](PATH environment variable configuration screenshot)


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.

![](ADB command verification output screenshot)


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

![](Connected device list output screenshot)


Common Connection Troubleshooting

If your device does not appear in the list:

  1. Make sure Developer Options and USB Debugging are enabled on your Android device
  2. Confirm that the correct USB driver for your device is installed on your PC
  3. Check if the default ADB port 5037 is occupied by another process
  4. Temporarily disable third-party antivirus software that may block ADB connecsions
  5. 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"
Tags: AndroidSDK

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.