This script connects to an Android device via ADB (Android Debug Bridge) and then mirrors the device screen using scrcpy. It allows the user to specify the device IP and port through an android-connect.yml file or via user input.
Ensure that the following dependencies are installed on your system:
adbscrcpyyq(for parsing YAML files)
You can install these dependencies using the package manager of your choice. For example, on Debian-based systems:
sudo apt-get update
sudo apt-get install adb scrcpy yq- Clone the repository using the following command:
git clone https://github.com/satrujit11/android-connect.git- Move to the cloned directory:
cd android-connect- Run the script using the following command:
./setup.sh- Clone the repository using the following command:
git clone https://github.com/satrujit11/android-connect.git- Move the script to /usr/local/bin:
sudo mv android-connect/android-connect.sh /usr/local/bin/android_connect- Make the script executable:
sudo chmod +x /usr/local/bin/android_connect- Run the script using the following command:
android_connectIf android_connect.yml is present in the current directory, the script will read the IP and port from this file. If the values are not specified in the file, it will use default values (192.168.29.137 for IP and 5555 for port).
If android_connect.yml is not present, the script will prompt you to enter the device IP and port. You can press Enter to use the default values.
device_ip: 192.168.1.10
device_port: 5555-
Save the current directory: The script saves the directory where it was initially run.
-
Check for configuration file: It checks if
android_connect.ymlexists and reads the device IP and port from it. -
Prompt for input: If the configuration file does not exist, it prompts the user to enter the device IP and port.
-
Navigate to platform-tools directory: Changes the directory to
~/Android/Sdk/platform-tools. -
Connect to the Android device:
- Connects to the device using the specified IP and port.
- Sets the device to use TCPIP mode on port
5555. - Reconnects to the device.
-
Return to the initial directory: Changes back to the original directory.
-
Run scrcpy: Mirrors the Android device screen using
scrcpy.
-
Ensure ADB is configured correctly: Make sure
adbis installed and added to your system PATH. -
Check device connection: Ensure your Android device is on the same network and the IP address is correct.
-
Verify dependencies: Make sure all dependencies (
adb,scrcpy,yq) are installed and up to date.
This script is licensed under the MIT License. Feel free to use and modify it as per your needs.