Configure devices for ADB debugging

更新时间:
复制 MD 格式

To use ADB debugging devices on a cloud computer, an administrator must configure the peripheral policy as described in this topic.

Prerequisites

If you use a hardware terminal, you must enable network ADB for your ADB devices first. Hardware terminals do not support USB-based ADB connections and only support network connections.

Hardware terminals

When you connect to a cloud computer through a hardware terminal (such as Alibaba Cloud Workspace Terminal, Alibaba Cloud Workspace Terminal Pro, or 23.8-inch Alibaba Cloud Workspace All-In-One Terminal), both the administrator and the end user must complete the following configuration steps.

Configure peripheral policies (administrator)

Peripheral management policies are part of the cloud computer policy, and must be created and maintained by an administrator in the console.

Note

The following examples use the EDS Enterprise Edition console. For the Business Edition procedure, see Manage policies.

General procedure for creating or modifying peripheral policies

Create a custom policy and associate it with a cloud computer

By default, a newly created cloud computer is associated with the system-generated default policy. Because the default policy cannot be modified, the administrator must create a custom cloud computer policy in the console and associate it with the cloud computer.

  1. Log on to the EDS enterprise console.

  2. In the left-side navigation pane, choose O&M > Policies.

  3. On the Policies page, click Create Policy.

  4. On the Create Policy page, enter a Policy Name as prompted, modify the policy settings as needed, and then click OK.

    After the policy is created, you can view it in the list on the Policies page.

  5. In the left-side navigation pane, choose Resource Management > EDS Enterprise.

  6. On the EDS Enterprise page, perform one of the following operations as needed:

    • Single operation: Find the target cloud computer, click More in the Actions column, and then select Change Policy.

    • Batch operation: Select one or more cloud computers, and then choose More > Change Policy at the bottom of the page.

  7. On the Required Policy tab of the Change Policy panel, click Change Policy, select the custom policy you created, and then click OK.

    Note

    If the resource group to which the cloud computer belongs already has an associated policy, you cannot directly change the policy for the cloud computer here. You can either change the policy associated with the resource group, or first remove the cloud computer from the resource group and then change its policy.

  8. At the bottom of the Change Policy panel, click OK, and then click Confirm Policy Change.

Modify a custom policy already associated with a cloud computer

If the cloud computer is already associated with a custom policy, the administrator can directly modify the policy in the console without re-associating it.

  1. Log on to the EDS enterprise console.

  2. In the left-side navigation pane, choose O&M > Policies.

  3. On the Policies page, find the custom policy you want to modify, and then click Modify Policy in the Actions column.

  4. On the Modify Policy page, modify the policy settings as needed, and then click OK.

Peripheral policy settings

Note

Hardware terminals do not support USB-based ADB connections and only support network connections. An administrator must configure network redirection to establish connectivity between the cloud computer and the phone.

Enable device redirection for ADB devices
  • Configuration path: Peripheral Control > Peripheral Redirection > ADB.

  • Configuration requirements: Set the redirection mode for ADB devices to Device Redirection.

    item_adb_device_redirection

Client-side configuration

Make sure the hardware terminal and the ADB device are on the same network. Using a phone as an example, open Settings, enable Developer options, and then enable Wireless debugging.

  1. Verify that the hardware terminal and the phone (under Wireless debugging) are on the same subnet.

    • On the hardware terminal, go to Settings > Network, select the network > Network Properties, and find the IPv4 address.

    • On the phone, go to Settings > Developer options > Wireless debugging, select the network, and note the IP address and port.

  2. On the phone, open Wireless debugging and tap Pair device with pairing code.

    image.jpeg

  3. After configuring the ADB environment on the cloud computer (see the Windows or Linux cloud computer tabs below), run the pairing command.

    adb pair <phone_IP>:<pairing_port>
    # Example: adb pair 10.1.30.130:37659
    # Use the IP and port shown on the phone under "Pair device with pairing code"
  4. After pairing succeeds, connect to the device. Use the IP and port displayed on the phone's Wireless debugging page under "IP address & Port".

    adb connect <phone_IP>:<connection_port>
    # Example: adb connect 10.1.30.130:35287
    # Use the IP and port shown under "IP address & Port"
  5. Verify the connection.

    adb devices

Windows client/macOS client

When you connect to a cloud computer by using the Windows client/macOS client, both the administrator and the end user must complete the following configuration steps.

Configure peripheral policies (administrator)

Peripheral management policies are part of the cloud computer policy, and must be created and maintained by an administrator in the console.

Note

The following examples use the EDS Enterprise Edition console. For the Business Edition procedure, see Manage policies.

General procedure for creating or modifying peripheral policies

Create a custom policy and associate it with a cloud computer

By default, a newly created cloud computer is associated with the system-generated default policy. Because the default policy cannot be modified, the administrator must create a custom cloud computer policy in the console and associate it with the cloud computer.

  1. Log on to the EDS enterprise console.

  2. In the left-side navigation pane, choose O&M > Policies.

  3. On the Policies page, click Create Policy.

  4. On the Create Policy page, enter a Policy Name as prompted, modify the policy settings as needed, and then click OK.

    After the policy is created, you can view it in the list on the Policies page.

  5. In the left-side navigation pane, choose Resource Management > EDS Enterprise.

  6. On the EDS Enterprise page, perform one of the following operations as needed:

    • Single operation: Find the target cloud computer, click More in the Actions column, and then select Change Policy.

    • Batch operation: Select one or more cloud computers, and then choose More > Change Policy at the bottom of the page.

  7. On the Required Policy tab of the Change Policy panel, click Change Policy, select the custom policy you created, and then click OK.

    Note

    If the resource group to which the cloud computer belongs already has an associated policy, you cannot directly change the policy for the cloud computer here. You can either change the policy associated with the resource group, or first remove the cloud computer from the resource group and then change its policy.

  8. At the bottom of the Change Policy panel, click OK, and then click Confirm Policy Change.

Modify a custom policy already associated with a cloud computer

If the cloud computer is already associated with a custom policy, the administrator can directly modify the policy in the console without re-associating it.

  1. Log on to the EDS enterprise console.

  2. In the left-side navigation pane, choose O&M > Policies.

  3. On the Policies page, find the custom policy you want to modify, and then click Modify Policy in the Actions column.

  4. On the Modify Policy page, modify the policy settings as needed, and then click OK.

Peripheral policy settings

Enable device redirection for ADB devices
  • Configuration path: Peripheral Control > Peripheral Redirection > ADB.

  • Configuration requirements: Set the redirection mode for ADB devices to Device Redirection.

    item_adb_device_redirection

Client-side configuration

Configure ADB environment variables on both the local device (client) and the cloud computer so that ADB commands are available. Choose the appropriate tab based on the operating system of the device.

Windows (client)
  1. In the Start menu, search for environment variables and click Edit the system environment variables.

  2. Add the ANDROID_HOME variable.

    1. In the System Properties dialog box, click the Advanced tab, and then click Environment Variables.

    2. Under System variables, click New.

    3. In the New System Variable dialog box, set the variable name to ANDROID_HOME and the variable value to the directory path of adb.exe (for example, D:\platform-tools), and then click OK.

  3. Edit the Path variable.

    1. Under System variables, select the variable named Path and click Edit.

    2. In the Edit environment variable dialog box, click New, enter %ANDROID_HOME%, and then click OK.

  4. Verify the configuration. Open Command Prompt and run adb. If the output includes an ADB version number, the environment variables are configured correctly.

macOS (client)

First, determine your shell type. Open Terminal and run echo $0. Based on the output (-zsh or -bash), choose the corresponding configuration file.

  • zsh (default shell): configuration file is ~/.zshrc or /etc/zshrc

  • bash: configuration file is ~/.bashrc or /etc/profile

  1. Open the corresponding configuration file.

  2. Add the following environment variables. Replace the path with the actual directory where the ADB tools are located.

    # Android ADB configuration
    export ANDROID_HOME=/Users/xxxx/Downloads/platform-tools
    export PATH=$PATH:$ANDROID_HOME
  3. Run the following command to apply the changes.

    # For zsh users
    source ~/.zshrc
    
    # For bash users
    source ~/.bashrc
  4. Verify the configuration. Open Terminal and run adb. If the output includes an ADB version number, the environment variables are configured correctly.

Windows (cloud computer)
  1. In the Start menu, search for environment variables and click Edit the system environment variables.

  2. Add the ANDROID_HOME variable.

    1. In the System Properties dialog box, click the Advanced tab, and then click Environment Variables.

    2. Under System variables, click New.

    3. In the New System Variable dialog box, set the variable name to ANDROID_HOME and the variable value to the directory path of adb.exe (for example, D:\platform-tools), and then click OK.

  3. Edit the Path variable.

    1. Under System variables, select the variable named Path and click Edit.

    2. In the Edit environment variable dialog box, click New, enter %ANDROID_HOME%, and then click OK.

  4. Verify the configuration. Open Command Prompt and run adb. If the output includes an ADB version number, the environment variables are configured correctly.

Linux (cloud computer)
  1. Open the shell configuration file (for example, ~/.bashrc or /etc/profile).

  2. Add the following environment variables. Replace the path with the actual directory where the ADB tools are located.

    # Android ADB environment variables
    export ANDROID_HOME=/opt/platform-tools
    export PATH=$PATH:$ANDROID_HOME
  3. Run source ~/.bashrc to apply the changes.

  4. Verify the configuration. Open a terminal and run adb. If the output includes an ADB version number, the environment variables are configured correctly.

The local device detects the ADB device, but the cloud computer does not

Symptom: The local device running the cloud computer session detects the ADB device, but the cloud computer cannot detect it.

Possible causes:

  • ADB environment variables are not configured on the client or the cloud computer.

  • ADB device redirection is not enabled in the console.

Solutions:

  • Configure ADB environment variables on both the client and the cloud computer. See Client-side configuration above.

  • Verify that the peripheral policy has ADB device redirection enabled. See Configure peripheral policies (administrator) above.

Troubleshooting