This tutorial guides you on how to connect a running virtual device to ADB in Genymotion SaaS.
Please note that you will need to use gmsaas CLI. Connecting an instance to ADB with its IP is not possible.
Requirements
- Python 3.10 or higher
- pip3 21.2.3 or higher
- Android SDK
- gmsaas CLI
Step 1 – Create an API token
An API token is necessary to authenticate gmsaas. Generate a token by following these steps.
1. Log in to your Genymotion SaaS portal. 2. Navigate to the “API” section. 3. Click on the “Create” button. 4. A popup opens. 5. Give an explicit description to your token. Use an example token description such as “gmsaas token”. 6. Click “CREATE”. 7. A new token is generated and displayed. 8. Click “COPY” to copy the token to your computer clipboard and save it somewhere. 9. When done, your new token will be displayed in the Your API Tokens section.
Step 2 – Install and configure gmsaas CLI
Before proceeding to this step, make sure that Python 3.8+ and pip3 20.9+ are installed on your workstation.
It is highly recommended to use a virtual Python environment. You can follow this tutorial for detailed instructions.
Install gmsaas
In a terminal or command shell, run this command:
pip3 install gmsaas
This installs gmsaas with all its dependencies. For more details about gmsaas installation, refer to gmsaas on-line user manual.
Authenticate
Authenticate gmsaas with the API token you generated in Step 1.
gmsaas auth token <token> # replace <token> with your API token.
Configure gmsaas
Configure the path to your Android SDK, where ADB is stored.
gmsaas config set android-sdk-path <sdk_path>
Replace <sdk-path> with the path to your Android SDK installation directory. Use a path similar to the ANDROID_SDK_ROOT or the deprecated ANDROID_HOME environment variables.
gmsaas does not support relative paths such as sdktools/ or ./sdktools.
> Note: Replace <sdk-path> with the path to your Android SDK installation directory, similar to the ANDROID_SDK_ROOT or the deprecated ANDROID_HOME environment variables.
> Warning: gmsaas does not support relative paths, such as sdktools/ or ./sdktools.
Verify
Check that gmsaas is properly set up with the gmsaas doctor command.
gmsaas doctor
Step 3 – Connect the device to ADB
Launch your device and copy its UUID.
You can copy the UUID from the Genymotion SaaS Virtual Devices dashboard. You can also get the UUID using the gmsaas instances list command.
gmsaas instances list
The output includes UUID, NAME, ADB SERIAL, and STATE.
UUID NAME ADB SERIAL STATE
------------------------------------ ---------------- ------------ -------
a8d382f9-633f-437f-bbcd-8907678071d4 Android 16 - JMA 0.0.0.0 BOOTING
Then run the following command to connect the device to ADB.
gmsaas instances adbconnect <instance_uuid> # replace <instance_uuid> with the UUID of the running device.
For example:
gmsaas instances adbconnect d1a6ffae-fd8d-4a37-bac4-0f185757f22c
The <instance_uuid> argument is now optional. If the argument is omitted, the command connects the single ONLINE instance. An error is raised if zero or more than one instance is ONLINE.
Your device should then be connected to adb. Verify the connection with the adb devices command.
For example:
adb devices
List of devices attached
localhost:44615 device
You can now pass adb commands to your virtual device.