Setting Up ADB on macOS: A Comprehensive Guide

Setting Up ADB on macOS: A Comprehensive Guide

30 November 2024 Stephan Petzl Leave a comment Tech-Help

Setting up ADB (Android Debug Bridge) on macOS can be a straightforward process if you follow the right steps. This guide provides a detailed explanation of various methods to install and configure ADB on your Mac, ensuring you can easily run Android applications on your device or emulator. Whether you prefer using package managers like Homebrew or setting it up manually, we’ve got you covered.

Option 1: Using Homebrew

Homebrew is a popular package manager for macOS that simplifies the installation of software. Here’s how you can use it to set up ADB:

  1. Install Homebrew by running the following command in your terminal:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  2. Install ADB with Homebrew:
    brew install android-platform-tools

    Alternatively, you can use the cask option if necessary:

    brew install --cask android-platform-tools
  3. Verify the installation by listing connected devices:
    adb devices

Option 2: Manual Installation

If you prefer a manual setup, follow these steps:

  1. Remove any previous ADB installations:
    rm -rf ~/.android-sdk-macosx/
  2. Download the SDK Platform-Tools for Mac from the Android Developer site.
  3. Unzip the downloaded file and move it to a permanent location:
    cd ~/Downloads/
    unzip platform-tools-latest*.zip
    mkdir ~/.android-sdk-macosx
    mv platform-tools/ ~/.android-sdk-macosx/platform-tools
  4. Add the platform-tools directory to your PATH:
    echo 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
  5. Refresh your terminal configuration:
    source ~/.bash_profile
  6. Verify the setup:
    adb devices

Option 3: With Android Studio

If you already have Android Studio installed, you can add ADB to your PATH using these commands:

echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.bash_profile
source ~/.bash_profile

Test your setup with:

adb devices

Option 4: Using MacPorts

MacPorts is another package manager that can be used for setting up ADB:

  1. Install the Android SDK:
    sudo port install android
  2. Run the SDK Manager and install only the Platform-tools:
    sh /opt/local/share/java/android-sdk-macosx/tools/android
  3. Add Platform-tools to your PATH:
    echo 'export PATH="$PATH:/opt/local/share/java/android-sdk-macosx/platform-tools"' >> ~/.bash_profile
  4. Refresh your terminal configuration:
    source ~/.bash_profile
  5. Verify the installation:
    adb devices

Option 5: Manual Setup with SDK Manager

For a more traditional setup, use the SDK Manager:

  1. Remove any existing installations:
    rm -rf ~/.android-sdk-macosx/
  2. Download the SDK Tools from the Android Developer site.
  3. Unzip and move the tools to a secure location:
    cd ~/Downloads/
    unzip tools_r*-macosx.zip
    mkdir ~/.android-sdk-macosx
    mv tools/ ~/.android-sdk-macosx/tools
  4. Run the SDK Manager and install Platform-tools.
  5. Add Platform-tools to your PATH:
    echo 'export PATH="$PATH:~/.android-sdk-macosx/platform-tools/"' >> ~/.bash_profile
  6. Refresh your terminal configuration:
    source ~/.bash_profile
  7. Check the ADB setup:
    adb devices

Enhancing Your Android Development with Repeato

For developers looking to streamline their testing processes, Repeato offers a robust solution. As a no-code test automation tool for iOS and Android, Repeato allows you to create, run, and maintain automated tests with ease. By leveraging computer vision and AI, Repeato ensures fast editing and execution of tests. Additionally, it comes equipped with ADB, enabling seamless execution of ADB commands through script steps, which can significantly enhance your testing workflow. To learn more about how Repeato can aid your development process, check out our Android Testing Tool documentation.

Like this article? there’s more where that came from!