This tool creates a virtual display on your Android device and streams it using scrcpy
. It's perfect for extending your Android device's screen or testing multi-display applications without additional hardware. The tool is available as both a Bash script (.sh) for Linux/macOS and a Batch file (.bat) for Windows.
- Computer running Windows, Linux, or macOS
- Android device with USB debugging enabled
- USB cable to connect your device
- Android Debug Bridge (ADB)
- Scrcpy
Don't worry if you don't have these yet - the setup guide below will walk you through installation!
-
Enable Developer Options:
- Go to Settings > About phone
- Tap Build number 7 times until you see "You are now a developer!"
-
Enable USB Debugging:
- Go back to Settings
- Find Developer options (may be under System or Advanced)
- Toggle on USB debugging
-
Connect Your Device:
- Connect your Android device to your computer using a USB cable
- When prompted on your Android device, tap Allow to authorize USB debugging
-
Download the Platform Tools:
- Go to Android Platform Tools
- Download the Windows ZIP file
-
Install ADB:
- Extract the ZIP file to a location you can easily find (e.g.,
C:\adb
) - Add the ADB location to your PATH:
- Right-click on Start > System
- Click Advanced system settings
- Click Environment Variables
- Under System Variables, find and select Path, then click Edit
- Click New and add the path to your ADB folder (e.g.,
C:\adb
) - Click OK on all dialogs
- Extract the ZIP file to a location you can easily find (e.g.,
-
Verify Installation:
- Open Command Prompt (search for "cmd" in Start menu)
- Type
adb version
and press Enter - You should see version information if installed correctly
-
Install ADB using package manager:
For Ubuntu/Debian:
sudo apt update sudo apt install adb
For macOS (using Homebrew):
brew install android-platform-tools
-
Verify Installation:
- Open Terminal
- Type
adb version
and press Enter - You should see version information if installed correctly
-
Download Scrcpy:
- Go to Scrcpy GitHub Releases
- Download the latest Windows release (scrcpy-win64-vX.XX.zip)
-
Install Scrcpy:
- Extract the ZIP file to a location you can easily find (e.g.,
C:\scrcpy
) - Add the Scrcpy location to your PATH (follow the same steps as for ADB)
- Extract the ZIP file to a location you can easily find (e.g.,
-
Verify Installation:
- Open Command Prompt
- Type
scrcpy --version
and press Enter - You should see version information if installed correctly
-
Install using package manager:
For Ubuntu/Debian:
sudo apt update sudo apt install scrcpy
For other distributions, check Scrcpy's documentation
-
Verify Installation:
- Open Terminal
- Type
scrcpy --version
and press Enter - You should see version information if installed correctly
-
Install using Homebrew:
brew install scrcpy
-
Verify Installation:
- Open Terminal
- Type
scrcpy --version
and press Enter - You should see version information if installed correctly
-
Download the Script:
- Save the
virtual_display.bat
file to a location on your computer
- Save the
-
Run the Script:
- Double-click the
virtual_display.bat
file - Alternatively, open Command Prompt, navigate to the script's location, and type
virtual_display.bat
- Double-click the
-
Download the Script:
- Save the
virtual_display.sh
file to a location on your computer
- Save the
-
Make the Script Executable:
- Open Terminal and navigate to the script's location
- Run
chmod +x virtual_display.sh
to make it executable
-
Run the Script:
- In Terminal, run
./virtual_display.sh
- In Terminal, run
- The script will create a virtual 1920x1080 display on your Android device
- Scrcpy will launch, showing this virtual display
- You can interact with this display using your mouse and keyboard
- When you're done, close the script window (or use Ctrl+C in Terminal) to remove the virtual display
-
"ADB is not installed or not in PATH":
- Make sure you've added the ADB folder to your PATH
- Try opening a new command window
- Try using the full path to adb in the script
-
"No Android device connected":
- Check your USB cable
- Make sure USB debugging is enabled
- Try unplugging and reconnecting your device
- On your Android device, check for a USB debugging authorization prompt
- Run
adb devices
to verify connection
-
"Failed to detect the new display ID":
- Some devices may have limitations with virtual displays
- Try modifying the script to increase the wait time (change
sleep 2
ortimeout /t 2
to a higher number)
-
"Scrcpy is not installed or not in PATH":
- Make sure you've added the Scrcpy folder to your PATH
- Try opening a new command window
- Try using the full path to scrcpy in the script
-
Virtual display appears but is glitchy:
- Try reducing the resolution in the script (change
1920x1080/240
to1280x720/240
) - Try reducing bitrate or FPS settings
- Try reducing the resolution in the script (change
-
Permission errors on Linux/macOS:
- Make sure the script is executable:
chmod +x virtual_display.sh
- If having issues with ADB, try running the script with sudo:
sudo ./virtual_display.sh
- Make sure the script is executable:
- Some Samsung devices require additional steps to enable Developer Options
- On newer Android versions, you may need to enable "Wireless debugging" even for USB connections
- Some devices may require specific USB drivers to work correctly with ADB
- Not all Android devices support virtual displays; this feature is typically available on devices running Android 4.4 (KitKat) or higher
You can modify the following parameters in the script:
-
Resolution: Change
1920x1080/240
to your preferred resolution (e.g.,3840x2160/480
for 4K)- Format is
WIDTHxHEIGHT/DPI
- Format is
-
Scrcpy settings:
- Bitrate: Change
-b 24M
to your preferred bitrate (lower for slower connections) - FPS: Change
--max-fps=60
to adjust frame rate - Window Title: Change
--window-title="Pixel"
to your preferred title
- Bitrate: Change
- You can create multiple virtual displays by running the script multiple times
- The virtual display persists on your device until explicitly removed
- The script automatically detects and uses the ID of the newly created display
Both scripts provide the same functionality but use platform-specific commands:
Feature | Linux/macOS (.sh) | Windows (.bat) |
---|---|---|
Command checking | command -v |
where |
Process delay | sleep 2 |
timeout /t 2 |
Text search | grep |
findstr |
Signal handling | trap cleanup EXIT |
Manual cleanup procedure |
Script execution | ./virtual_display.sh |
virtual_display.bat |
Feel free to suggest improvements or report issues by contacting the script author.
This project is available for free use and modification.
This script modifies your Android device settings. While it's designed to clean up after itself, always ensure you have important data backed up before using tools that modify system settings.