Introduction to ADB (Android Debug Bridge)
๐ฏ Learning Objectives
- Understand what ADB is and why it is useful.
- Install and configure ADB on macOS.
- Connect an Android phone using ADB.
- Perform basic ADB operations such as listing files, transferring files, and accessing device shell.
1. ๐ What is ADB?
ADB (Android Debug Bridge) is a command-line tool that allows communication between your computer and an Android device. It is used by developers and advanced users to:
- Debug apps
- Transfer files
- Access internal system logs
- Run shell commands on the Android device
2. โ๏ธ Installation on macOS
Step 1: Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install ADB using Homebrew
brew install android-platform-tools
3. ๐ฒ Enable USB Debugging on Android
On Your Phone (e.g., Oppo F7):
- Go to Settings > About Phone
- Tap Build Number 7 times to enable Developer Options
- Go to Settings > Additional Settings > Developer Options
- Enable USB Debugging
4. ๐ Connect Phone to Mac
- Use a USB data cable
- Set USB mode to File Transfer (MTP)
- Accept โAllow USB debuggingโ prompt on your phone
5. ๐ป Verify ADB Connection
Command:
adb devices
Expected output:
List of devices attached
ABC1234567 device
If it says unauthorized, check your phone for the prompt and tap Allow.
6. ๐งช Common ADB Commands
๐ List files on phone storage:
adb shell ls /sdcard/
๐ฅ๏ธ Start a shell session inside the phone:
adb shell
๐ค Copy file from phone to Mac:
adb pull /sdcard/DCIM/Camera/IMG_20230605_103214.jpg ~/Pictures/
๐ฅ Copy file from Mac to phone:
adb push myfile.pdf /sdcard/Download/
๐งน Delete a file from phone:
adb shell rm /sdcard/Download/myfile.pdf
7. ๐ธ Access Camera Folder
View contents:
adb shell ls /sdcard/DCIM/Camera
Copy all camera images:
adb pull /sdcard/DCIM/Camera ~/Pictures/OppoCamera
8. ๐งฐ Optional: Automate with a Script
You can create a simple sync script to pull new photos from your phone automatically. Ask the instructor for details.
๐ Summary
| Task | Command |
|---|---|
| Install ADB | brew install android-platform-tools |
| Connect device | adb devices |
| Enter phone shell | adb shell |
| List phone files | adb shell ls /sdcard/ |
| Pull file from phone | adb pull <source> <destination> |
| Push file to phone | adb push <source> <destination> |
| Delete file | adb shell rm <path> |
๐ References
- Official Android ADB Docs
man adb(if installed via Homebrew)