๐ŸŽฏ 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):

  1. Go to Settings > About Phone
  2. Tap Build Number 7 times to enable Developer Options
  3. Go to Settings > Additional Settings > Developer Options
  4. 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