Running on a Physical Android Device (Lightweight — scrcpy)
Setting up scrcpy (Screen Copy) is fast, lightweight, and takes less than 5 minutes. Here is the step-by-step guide to get it up and running on your Mac.
1. Install scrcpy and ADB on your Mac
Make sure Homebrew is installed first. Open your Mac Terminal app and run:
brew install scrcpy android-platform-tools
This installs both scrcpy and adb (Android Debug Bridge), which scrcpy uses to talk to your phone.
2. Enable Developer Options on your Android Phone
Unlocks USB debugging mode. On your Android device:
- Open Settings > About Phone.
- Tap Build Number 7 times until you see the message: “You are now a developer!”
3. Enable USB Debugging
Allows your Mac to communicate with your phone.
- Go back to main Settings > System (or Additional Settings).
- Open Developer options.
- Toggle USB debugging to ON.
4. Connect & Authorize Your Mac
First-time pair prompt.
- Plug your phone into your Mac using a USB cable.
- Look at your phone’s screen. A prompt will appear asking: “Allow USB debugging?”
- Check the box for “Always allow from this computer” and tap Allow.
5. Launch scrcpy
Start mirroring. In your Mac Terminal, simply run:
scrcpy
A window will immediately pop up showing your phone’s screen!
Key Shortcuts & Tips
Once the window is open, you can control your phone completely with your Mac’s keyboard and mouse:
- Left Click / Drag: Tap / Swipe
- Right Click: Back button
- Middle Click (Scroll Wheel): Home button
- Clipboard sharing: Copying text on your Mac (
Cmd + C) lets you paste it on your phone (Ctrl + V). - Turn off phone screen while mirroring: Run
scrcpy --turn-screen-offto save phone battery while using it from your Mac.
Wireless Mode (Optional)
If you don’t want to use a USB cable every time, connect via USB once, then run:
scrcpy --tcpip
You can then unplug the cable, and it will connect wirelessly over your Wi-Fi network!
Installing Android SDK Build Tools (for flutter run)
scrcpy only needs adb, but building and running the Flutter app on a device (flutter run) needs the full Android SDK build tools (aapt, build-tools, platforms). If you see an error like Could not locate aapt, follow these steps.
Step 1: Install Android Command Line Tools
brew install --cask android-commandlinetools
Step 2: Set Environment Variables
Add the Android SDK location to your shell configuration file. Open your zsh config:
nano ~/.zshrc
Paste the following lines at the bottom:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/build-tools/34.0.0
Save and exit (press Ctrl + O, then Enter, then Ctrl + X), then reload:
source ~/.zshrc
Step 3: Tell Flutter Where the Android SDK Is
flutter config --android-sdk "$HOME/Library/Android/sdk"
Step 4: Set Up the Command-Line Tools Structure
Homebrew puts cmdline-tools in its own cellar folder, but Flutter specifically looks for a cmdline-tools/latest directory inside your ANDROID_HOME. The actual tools (including sdkmanager) live one level deeper than the cask’s top folder, at .../android-commandlinetools/cmdline-tools/latest.
Run these commands to link Homebrew’s sdkmanager to where Flutter looks for it:
# Create the directory structure Flutter expects
mkdir -p $HOME/Library/Android/sdk/cmdline-tools
# Find where Homebrew installed it and create a symlink to 'latest'
# (For Apple Silicon M1/M2/M3/M4 Macs):
ln -sfn /opt/homebrew/share/android-commandlinetools/cmdline-tools/latest $HOME/Library/Android/sdk/cmdline-tools/latest
Note: if you are on an older Intel-based Mac, replace
/opt/homebrew/with/usr/local/in the command above (i.e./usr/local/share/android-commandlinetools/cmdline-tools/latest). Rununame -mif you’re not sure which Mac you have —arm64is Apple Silicon,x86_64is Intel.
Verify sdkmanager now resolves inside the symlinked bin folder:
ls $HOME/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager
which sdkmanager
Step 5: Install Required Build Tools & Platform
mkdir -p $HOME/Library/Android/sdk
sdkmanager --sdk_root=$HOME/Library/Android/sdk "build-tools;34.0.0" "platforms;android-34" "platform-tools"
Step 6: Accept Android Licenses
flutter doctor --android-licenses
Press y and hit Enter for every license prompt that appears.
Step 7: Test Flutter Setup
flutter doctor
Once flutter doctor shows green checkmarks for the Android toolchain, head back to your project directory and re-run your app:
flutter run --flavor tenantADev --dart-define-from-file=env/local.json