ADB Setup for Android Development
This guide will walk you through setting up Android Debug Bridge (ADB) on your development machine. ADB is a command-line tool that allows you to communicate with Android devices for debugging, installing apps, and accessing device features.
What is ADB?
Android Debug Bridge (ADB) is a versatile command-line tool that lets you:
- Install and debug Android applications
- Access a Unix shell on your Android device
- Transfer files between your computer and device
- View device logs and system information
- Enable USB debugging and manage device connections
Prerequisites
- An Android device (phone or tablet) running Android 4.0 or higher
- A USB cable to connect your device to your computer
- Administrator/sudo access on your development machine
Installation
macOS
Option 1: Using Homebrew (Recommended)
brew install android-platform-tools
Option 2: Manual Installation
- Download the Command Line Tools from Android Developer website
- Extract the ZIP file to a location like
~/Library/Android/sdk - Add ADB to your PATH by editing
~/.zshrcor~/.bash_profile:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
- Reload your shell configuration:
source ~/.zshrc # or source ~/.bash_profile
Windows
Option 1: Using Chocolatey
choco install adb
Option 2: Using Scoop
scoop install adb
Option 3: Manual Installation
-
Download the Command Line Tools from Android Developer website
-
Extract the ZIP file to a location like
C:\Android\sdk -
Add ADB to your PATH:
- Open System Properties > Environment Variables
- Under System Variables, find and select Path, then click Edit
- Click New and add:
C:\Android\sdk\platform-tools - Click OK to save
-
Open a new Command Prompt or PowerShell window
Linux
Option 1: Using Package Manager
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot
Fedora:
sudo dnf install android-tools
Arch Linux:
sudo pacman -S android-tools
Option 2: Manual Installation
- Download the Command Line Tools from Android Developer website
- Extract the ZIP file to a location like
~/Android/sdk - Add ADB to your PATH by editing
~/.bashrcor~/.zshrc:
export ANDROID_HOME=$HOME/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
- Reload your shell configuration:
source ~/.bashrc # or source ~/.zshrc
Verify Installation
After installation, verify that ADB is working correctly:
adb version
You should see output like:
Android Debug Bridge version 1.0.41
Version 33.0.3-8952118
Setting Up Your Android Device
Step 1: Enable Developer Options
- Open Settings on your Android device
- Navigate to About phone (or About device)
- Find Build number and tap it 7 times
- You'll see a message saying "You are now a developer!"
Step 2: Enable USB Debugging
- Go back to Settings
- Navigate to Developer options (usually under System or Advanced)
- Enable USB debugging
- If prompted, tap OK to confirm
Step 3: Connect Your Device
- Connect your Android device to your computer using a USB cable
- On your device, you may see a prompt asking "Allow USB debugging?"
- Check "Always allow from this computer" (optional but recommended)
- Tap OK
Step 4: Verify Connection
Run the following command to verify your device is connected:
adb devices
You should see output like:
List of devices attached
ABC123XYZ456 device
If you see unauthorized instead of device, you need to:
- Check your device screen for the USB debugging authorization prompt
- Tap Allow on the prompt
- Run
adb devicesagain
Common ADB Commands
Here are some useful ADB commands for development:
Check Connected Devices
adb devices
Install an APK
adb install path/to/app.apk
This is particularly useful for installing Formulus APK files or other ODE applications for testing.
Install with Replace (upgrade existing app)
adb install -r path/to/app.apk
Uninstall an App
adb uninstall com.example.package
View Device Logs
adb logcat
Filter Logs by Tag
adb logcat -s TAG_NAME
Clear Logs
adb logcat -c
Pull File from Device
adb pull /sdcard/file.txt ~/Desktop/
Push File to Device
adb push ~/Desktop/file.txt /sdcard/
Open Shell on Device
adb shell
Reboot Device
adb reboot
Reboot to Bootloader
adb reboot bootloader
Port Forwarding (Reverse)
adb reverse tcp:LOCAL_PORT tcp:DEVICE_PORT
This forwards a port from your Android device to your local machine. Very useful for connecting to local development servers (see ODE Development Workflow below).
Troubleshooting
Device Not Showing Up
Issue: adb devices shows no devices or shows unauthorized
Solutions:
- Check USB cable: Try a different USB cable (some cables are charge-only)
- Check USB port: Try a different USB port on your computer
- Check USB mode: On your device, when connected, pull down the notification shade and ensure USB mode is set to File Transfer or MTP (not Charge only)
- Revoke USB debugging: In Developer options, tap Revoke USB debugging authorizations, then reconnect
- Restart ADB server:
adb kill-server adb start-server adb devices
macOS: "adb: command not found"
Solution: Make sure you've added ADB to your PATH and reloaded your shell:
echo 'export PATH=$PATH:$HOME/Library/Android/sdk/platform-tools' >> ~/.zshrc
source ~/.zshrc
Windows: "adb is not recognized"
Solution:
- Verify ADB is in your PATH by checking
C:\Android\sdk\platform-tools\adb.exeexists - Open a new Command Prompt window (PATH changes require a new session)
- Try the full path:
C:\Android\sdk\platform-tools\adb.exe devices
Linux: Permission Denied
Solution: Create a udev rule for your device:
-
Find your device's vendor ID:
lsusbLook for your device and note the ID (e.g.,
18d1:4ee2) -
Create a udev rule file:
sudo nano /etc/udev/rules.d/51-android.rules -
Add a line (replace
18d1with your vendor ID):SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0664", GROUP="plugdev" -
Set permissions:
sudo chmod a+r /etc/udev/rules.d/51-android.rules sudo udevadm control --reload-rules sudo udevadm trigger -
Add your user to the plugdev group:
sudo usermod -aG plugdev $USER(You'll need to log out and back in for this to take effect)
Device Shows as "Offline"
Solutions:
- Disconnect and reconnect the USB cable
- Restart ADB server:
adb kill-server adb start-server - On your device, toggle USB debugging off and on again
- Try a different USB cable or port
Wireless ADB (Advanced)
For wireless debugging (Android 11+), you can connect via Wi-Fi:
- Connect your device via USB first
- Enable Wireless debugging in Developer options
- Note the IP address and port shown
- Run:
adb connect IP_ADDRESS:PORT - You can now disconnect the USB cable
Next Steps
Now that ADB is set up, you can:
- Install and test Android applications
- Debug apps using
adb logcat - Transfer files between your computer and device
- Access device shell for advanced operations
Developing Formulus with React Native
Once ADB is configured and your Android device is connected, you can develop Formulus using React Native:
-
Navigate to the Formulus folder in your terminal:
cd path/to/formulus -
Run the React Native app on your connected Android device:
npx react-native run-androidThis command will:
- Build the React Native app
- Install it on your connected Android device via ADB
- Start the Metro bundler
-
Enable Hot Reload (optional): In a separate terminal window, start the Metro bundler:
npx react-native startThe app will automatically update (hot reload) whenever you modify the React Native code, just like a website would refresh in a browser.
Note: Make sure your device is connected and visible with adb devices before running the React Native commands.
Connecting to Local Synkronus Server
When developing with ODE, you often need to connect Formulus running on your Android device to a local Synkronus server running on your development machine. Use ADB port forwarding to make this seamless:
-
Start your local Synkronus server on your development machine (e.g., on port 8080)
-
Forward the port from your Android device to your local machine:
adb reverse tcp:8080 tcp:8080This command forwards port 8080 on your Android device to port 8080 on your local machine.
-
Configure Formulus to use
http://localhost:8080as the server URL. The app will connect to your local Synkronus server through the forwarded port.
Example Workflow:
# Terminal 1: Start Synkronus server locally
./synkronus # Running on localhost:8080
# Terminal 2: Forward the port
adb reverse tcp:8080 tcp:8080
# Now Formulus on your Android device can connect to http://localhost:8080
# and it will reach your local Synkronus server
This setup allows you to develop and test the full ODE stack locally without deploying to a remote server.
Other ODE Development Tasks
For ODE-specific development, you can now:
- Install Formulus APK files for testing
- View logs from Synkronus server interactions
- Debug custom applications built with ODE
Additional Resources
Need Help?
If you encounter issues not covered here, please:
- Check the Android Developer Forums
- Reach out to the ODE community at [email protected]