Platform tools & ADB

Install Android platform tools and use adb to install apps, send files to the phone, take screenshots and control the device from your computer.

Install platform tools

Platform tools is Google's free package that includes adb (Android Debug Bridge). Android Studio already includes it, but you don't need Android Studio to use it.

macOS

With Homebrew:

brew install --cask android-platform-tools

Or download the zip for Mac from the platform tools page, extract it to your home folder and add it to your PATH:

echo 'export PATH="$PATH:$HOME/platform-tools"' >> ~/.zshrc
source ~/.zshrc

Windows

  1. Download the zip for Windows from the platform tools page.
  2. Extract it to C:\platform-tools.
  3. Open Edit the system environment variables › Environment Variables, select Path, click Edit › New and add C:\platform-tools.
  4. Open a new terminal window so it picks up the change.

Linux

Download the zip for Linux from the same page and add the folder to your PATH, as on macOS. Packages from your distribution (for example apt install adb) also work but are often older.

Check that it works

adb version

Turn on USB debugging

  1. On the phone, open Settings › About phone.
  2. Tap Build number seven times until you see "You are now a developer".
  3. Go back to Settings › System › Developer options.
  4. Turn on USB debugging.

The location of Build number and Developer options varies by brand. On Samsung, Build number is in About phone › Software information.

Connect the device

  1. Connect the phone with a USB cable and unlock it.
  2. Run adb devices.
  3. Accept the Allow USB debugging? prompt on the phone.
  4. Run adb devices again. The device should show as device.
adb devices
List of devices attached
R58M12ABCDE    device

With more than one device or emulator connected, every command needs to say which one to use. See Choose the device.

Wireless debugging (Android 11 and later)

  1. Connect the phone and computer to the same Wi-Fi network.
  2. In Developer options, turn on Wireless debugging and tap Pair device with pairing code.
  3. Pair with the IP address, port and code shown on the phone:
adb pair 192.168.1.20:37000
adb connect 192.168.1.20:41000

The pairing port and the connection port are different. The connection port is shown on the main Wireless debugging screen.

Send files to the phone

adb push copies a file or folder from your computer to the phone. Files in /sdcard/Download/ show up in the phone's Downloads folder.

# Send one file
adb push test-document.pdf /sdcard/Download/

# Send a whole folder
adb push test-images/ /sdcard/Download/test-images/

# Check that it arrived
adb shell ls /sdcard/Download/

adb pull does the opposite and copies from the phone to your computer:

# Copy into the current folder
adb pull /sdcard/Download/test-document.pdf .

# Copy all camera photos
adb pull /sdcard/DCIM/Camera/ ./photos/
Use quotes for spacesIf a file or folder name has spaces, wrap the path in quotes, for example adb push "my file.pdf" /sdcard/Download/.

Choose the device when more than one is connected

If two or more phones, tablets or emulators are connected, adb doesn't know where to send the file and stops with this error:

adb: more than one device/emulator
  1. List the connected devices with their model names:
adb devices -l
List of devices attached
R58M12ABCDE          device usb:1-1 product:a54xnsxx model:SM_A546E device:a54x
emulator-5554        device product:sdk_gphone64_arm64 model:sdk_gphone64_arm64
192.168.1.20:41000   device product:panther model:Pixel_7 device:panther
  1. Find the device you want by its model and copy the ID in the first column. USB devices show a serial number, emulators show emulator- plus a port, and wireless devices show their IP address and port.
  2. Add -s and that ID right after adb:
# Send a file to the Samsung only
adb -s R58M12ABCDE push test-document.pdf /sdcard/Download/

# Send the same file to the emulator
adb -s emulator-5554 push test-document.pdf /sdcard/Download/

# Works with every command, not only push
adb -s 192.168.1.20:41000 install app.apk

To skip typing -s every time, set the device once for the current terminal window:

# macOS and Linux
export ANDROID_SERIAL=R58M12ABCDE

# Windows (PowerShell)
$env:ANDROID_SERIAL="R58M12ABCDE"

# Now this goes to R58M12ABCDE
adb push test-document.pdf /sdcard/Download/

Shortcuts: -d uses the only device connected by USB, and -e uses the only running emulator, for example adb -d push test-document.pdf /sdcard/Download/.

Install and manage apps

# Install an APK
adb install app.apk

# Reinstall and keep the app data
adb install -r app.apk

# Install an older version over a newer one
adb install -r -d app.apk

# Install an app split into several APKs
adb install-multiple base.apk config.en.apk config.xxhdpi.apk

# Uninstall
adb uninstall com.example.app
# Find a package name
adb shell pm list packages | grep example

# Show the installed version
adb shell dumpsys package com.example.app | grep versionName

# Open the app
adb shell monkey -p com.example.app 1

# Close the app
adb shell am force-stop com.example.app

# Clear all app data (like a fresh install)
adb shell pm clear com.example.app

# Grant a permission
adb shell pm grant com.example.app android.permission.CAMERA

Read logs

Logcat shows the device's live log. For collecting crashes for a bug report, see Android crash & error logs.

# Show warnings and errors with timestamps
adb logcat -v time *:W

# Show only one app
adb logcat --pid=$(adb shell pidof -s com.example.app)

# Clear old logs, then save new ones to a file (stop with Ctrl+C)
adb logcat -c
adb logcat -v time > logcat.txt

# Save only the crash messages
adb logcat -b crash -d > crash.txt

# Full bug report with logs and system info
adb bugreport bugreport.zip

The --pid example works on macOS and Linux. On Windows, run adb shell pidof -s com.example.app first and use the number it prints.

Screenshots and screen recordings

# Screenshot straight to your computer
adb exec-out screencap -p > screen.png

# Record the screen, stop with Ctrl+C (3 minutes max)
adb shell screenrecord /sdcard/Download/recording.mp4
adb pull /sdcard/Download/recording.mp4 .

Device information

# Model and Android version
adb shell getprop ro.product.model
adb shell getprop ro.build.version.release

# Screen size and density
adb shell wm size
adb shell wm density

# Battery status
adb shell dumpsys battery

Testing shortcuts

# Open a URL or deep link
adb shell am start -a android.intent.action.VIEW -d "https://qa1337.com"

# Type text into the focused field (%s is a space)
adb shell input text "hello%sworld"

# Press Back, Home or Enter
adb shell input keyevent KEYCODE_BACK
adb shell input keyevent KEYCODE_HOME
adb shell input keyevent KEYCODE_ENTER

# Dark mode on and off
adb shell cmd uimode night yes
adb shell cmd uimode night no

# Simulate a smaller screen, then reset
adb shell wm size 1080x1920
adb shell wm size reset

# Turn animations off for stable automated tests
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0

# Restart the device
adb reboot

Troubleshooting

Problem Fix
adb: command not found Platform tools is not in your PATH. Open a new terminal or check the install steps.
Device shows unauthorized Unlock the phone and accept the USB debugging prompt. If it doesn't appear, unplug and plug the cable again.
No devices listed Try another cable or port. Some cables only charge. Then run adb kill-server and adb devices.
INSTALL_FAILED_VERSION_DOWNGRADE The phone has a newer version. Use adb install -r -d or uninstall first.
INSTALL_FAILED_UPDATE_INCOMPATIBLE The installed app was signed with a different key. Uninstall it first.