Virtual Remote USB Devices with TestGrid

You are here:
< All Topics

Overview

Virtual USB (vUSB) is a mobile debugging tool that replicates the experience of connecting a TestGrid Real Devices Cloud to your personal computer via a USB cable. This allows you to debug applications using your preferred in-house development and testing tools as if the device were directly connected to your workstation.

Key Features:

  • Build and deploy apps directly from any IDE (e.g., Android Studio, Xcode).
  • Streamline early-stage development workflows.
  • Combine live and automated testing as per your requirements.
  • Monitor device performance metrics such as CPU consumption, memory usage, and network performance (dependent on your IDE/tools).

Note: Virtual USB is exclusively for debugging purposes; local hosted automation script execution runs or manually connections; and currently supports iOS 17 and below versions; For iOS only, not supported on OS 17 and higher versions.

Prerequisites

  • A TestGrid account credentials.
  • A system running Windows, macOS, or Linux.
  • Administrative rights to install software on your machine.
  • Java Development Kit (JDK) installed.

For iOS App Testing:

  • macOS or Linux (not supported on Windows).
  • Xcode installed (macOS only).

For Android App Testing:

  • Android Debug Bridge (ADB) version 1.0.39 or higher.
  • Android Studio version 4 or higher.

 

Step 1: Go to the TestGird Portal and find a left-side navigation Virtual USB option.

  • After clicking on the Virtual USB option, you will see the option to download virtual USB.jar.

 

 

 

 

 

Step 2: Establish a Connection to the Real Device Cloud

Launch the command prompt on your local machine and execute the following command:

$ sudo java -jar RemoteUSB.jar Server --userToken <your_token> --server https://<your_domain>.testgrid.io

 

Note:Virtual USB requires Java version 20 or higher. Ensure your local machine meets this requirement.

Learn how to obtain your user token.

Step 3: Accept Application Execution

A pop-up will appear requesting permission to execute the application. Click Allow. After executing the command, the session data log will run in the background. Do not close the session or the terminal.

 

Step 4: List Available Devices

Run the following command to get a list of available devices along with their status, connection details, and server information:

$ java -jar RemoteUSB.jar List

To check the status of devices, use:

$ java -jar RemoteUSB.jar Status

If you encounter any issues, restart the services using:

$ java -jar RemoteUSB.jar RestartServices

Restarting the services can help resolve issues when the system becomes unresponsive.

 

 

 

Step 5: To Connect to a Device

To start a session with a specific device, run:

$ java -jar RemoteUSB.jar Connect <UDID>

Upon successful connection, the prompt will confirm the connection.

 

 

Step 6: Verify Device Connection

  • For Xcode, the connected device will appear, allowing developers to design, code, test, and debug with a unified workflow.
  • For Android, use the command line or Android Studio to verify the connection:
$ scrcpy

 

 

Step 7: To Disconnect the Device

To disconnect the device from the cloud, execute:

$ java -jar RemoteUSB.jar Disconnect <UDID>

Upon successful execution, the prompt will confirm the disconnection.

 

 

Troubleshooting Guide: Device List Command Issues

When running the device list command, you might encounter errors. Here’s how to troubleshoot and resolve them:

1. Error: java.io.IOException HTTP Error: 500

  • This error indicates a server issue.
  • Solution: Reach out to the support team at support@testgrid.io for assistance.

2. Error: adb devices shows devices as offline

  • This happens when ADB (Android Debug Bridge) loses connection with the devices.
  • Solution:
    1. Run the command: adb kill-server
    2. Restart the ADB service by running: adb start-server
    3. Retry the command to get the device list.
    4. Ensure the device is properly connected and authorized.

3. Restarted a virtual USB service on the server using the below command.

java -jar RemoteUSB.jar RestartServices

4. Ensuring a Seamless Execution

  • After restarting the ADB server, run the JAR file and execute the device list command again.
  • This should establish a proper connection and fetch the list successfully.

 

To setup adb for sudo users in CLI :

echo 'Defaults secure_path = /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' | sudo tee -a /etc/sudoers > /dev/null

 

Conclusion

With Virtual USB, debugging becomes seamless and efficient, enabling you to harness the power of TestGrid Real Devices Cloud as if the devices were physically connected to your local machine.

Happy Testing!

 

 

 

 

Table of Contents