Connect to ADB¶
ADB is a communication protocol specific to Android that allows to connect or control an Android device from a computer.
It can be used with a Genymotion Device image instance to:
- Control an instance Android OS.
- Connect an instance to a developer's tool (IDE), such as Android Studio, VS Code, JetBrains Rider, etc.
- Access an instance shell.
- Upload files to an instance.
Prerequisite¶
- Android SDK platform-tools from https://developer.android.com or Android Studio.
Android Studio
The Android SDK platform-tools are included with Android Studio. By default, they are located in the following folders:
Enable or disable ADB¶
When enabling ADB, your instance becomes accessible using the standard 5555 TCP port. Since the ADB connection is neither secured nor authenticated, we strongly recommend to only open TCP port 5555 to specific hosts in your Security Group and/or EC2 Firewall.
Instead of opening TCP port 5555, you can use an SSH tunnel to make a secure the connection.
-
Go to the Configuration panel:
-
In the ADB section, click on the toggle button to enable or disable ADB access:
Setup SSH and use the following commands:
You can use the POST
method and call the /configuration/adb
API to set the following variables:
- Set
active:true
to enable ABD at run-time, and/oractive_on_reboot:true
to enable after reboot. - Set
active:false
to disable ADB at run-time, and/oractive_on_reboot:false
to disable after reboot.
For detailed usage, please refer to Genymotion HTTP API.
You can then connect the instance to ADB:
Use an SSH tunnel¶
Though it is possible to open TCP port 5555 to restricted hosts in your EC2 firewall, using an SSH tunnel is the most secured method.
1. Create an ssh tunnel¶
From a new terminal/shell create an SSH tunnel:
Do not close this terminal/shell or this will close the tunnel as well.
To create a tunnel for other virtual devices, just increment the port number for every new virtual device (5556, 5557, 5558, etc.).
With PuTTy
- Set PuTTy to connect to your instance.
- Go to Connection > SSH > Tunnels and set
Source port
to 5555 andDestination
to localhost:5555. - Click on Add.
- Click on Open to start the connection.
The PuTTy terminal has to remain open during your operations. If PuTTY is closed, it will close the tunnel as well.
To create a tunnel for other virtual devices, make sure you increment the port number for every new virtual device (5556, 5557, 5558, etc.)
2. Connect ADB to the instance¶
- Open another shell to run other commands.
- Connect your virtual device to ADB:
To connect other virtual devices to ADB, make sure you increment the port number for every new virtual device (e.g. 5556, 5557, 5558, etc.). For example:
Then, to connect this instance to ADB: