How to connect a virtual device to ADB in Genymotion SaaS?

This tutorial will guide you on how to connect a running virtual device to ADB in Genymotion SaaS.

Requirements

Step 1 – Create an API token

An API token is necessary to authenticate gmsaas. To generate a token, please follow these steps:

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.

Also, 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 will install gmsaas with all its dependencies. For more details about gmsaas installation, please refer to gmsaas on-line user manual.

Authenticate

You need to authenticate gmsaas with the API token you generated in Step 1:

gmsaas auth token <token>  # replace <token> with your API token.

Configure gmsaas

Next, you need to configure the path to your Android SDK, where ADB is stored:

gmsaas config set android-sdk-path <sdk_path>

> 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.

> gmsaas does not support relative paths, such as sdktools/ or ./sdktools

Verify

Check that gmsaas is properly setup with the gmsaas doctor command:

gmsaas doctor

Step 3 – Connect the device to ADB

Launch your device and copy its UUID:

Genymotion SaaS Virtual Devices dashboard

> Note: You can also use the command gmsaas instances list to easily get your device UUID.

then run the following command:

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

Your device should then be connected to adb. You can verify with the adb devices command. For example:

$ adb devices
List of devices attached
localhost:44615 device
$

And that’s it! You can now pass adb commands to your virtual device!