How to Connect with NativeBridge Using ADB: Advanced Testing Capabilities in Your Browser

![NativeBridge ADB Connection Header Image]

Introduction

NativeBridge revolutionizes mobile app testing by bringing native mobile apps directly to your browser. While our browser-based interface is powerful on its own, power users can take testing to the next level by connecting their local development environment directly to NativeBridge's remote devices using the Android Debug Bridge (ADB).

This guide will walk you through establishing an ADB connection with devices running in NativeBridge, opening up advanced testing and debugging capabilities that seamlessly bridge your local development environment with our cloud-hosted devices.

What is ADB and Why Use It with NativeBridge?

Android Debug Bridge (ADB) is a versatile command-line tool that enables direct communication between your development machine and Android devices. When combined with NativeBridge, ADB unlocks powerful capabilities:

  • Run automated tests directly against remote devices
  • Push and pull files between your local machine and the remote device
  • Install APKs directly from your development pipeline
  • Access device logs for deeper debugging
  • Use tools like scrcpy for enhanced device control

Prerequisites

Before getting started, ensure you have:

  1. An active NativeBridge account with a running device session
  2. ADB installed on your local machine
    • For Windows: Install via Android Studio or download the Platform Tools directly
    • For macOS: Install via brew install android-platform-tools
    • For Linux: Install via your package manager or download Platform Tools

Connecting to a NativeBridge Device via ADB

Step 1: Launch Your Device Session

Start by launching a device session in NativeBridge. This can be either an emulated device or a real physical device.

Step 2: Access the ADB Connection Details

  1. In your active device session, locate and click the "Connect With ADB" button in the device control panel.
  2. A modal will appear displaying a connection command in the format: adb connect <deviceURL>
  3. This URL is a unique identifier for your specific device session.

![Screenshot of NativeBridge ADB connection modal]

Step 3: Establish the ADB Connection

  1. Copy the entire adb connect <deviceURL> command from the modal.
  2. Open your terminal or command prompt.
  3. Paste and execute the command:
adb connect device-id-12345.devices.nativebridge.io:7000
  1. If successful, you should see a confirmation message: connected to device-id-12345.devices.nativebridge.io:7000

Step 4: Verify the Connection

To confirm your device is properly connected, run:

adb devices

You should see your NativeBridge device listed in the output, showing the status as "device":

List of devices attached
device-id-12345.devices.nativebridge.io:7000    device

Leveraging scrcpy for Enhanced Control

While NativeBridge provides a full browser-based interface, you can also use scrcpy (screen copy) for an alternative way to view and control your remote device with potentially lower latency.

Setting Up scrcpy

  1. Install scrcpy on your local machine:
    • For Windows: Use Chocolatey: choco install scrcpy
    • For macOS: Use Homebrew: brew install scrcpy
    • For Linux: Use your package manager (e.g., apt install scrcpy)

Connecting with scrcpy

  1. With your ADB connection established, run the following command:
scrcpy -s device-id-12345.devices.nativebridge.io:7000
  1. A new window will open displaying your remote device screen, which you can control using your mouse and keyboard.

Common ADB Commands for NativeBridge Testing Workflows

Once connected, you can use standard ADB commands to interact with your NativeBridge device:

Installing Apps

adb -s device-id-12345.devices.nativebridge.io:7000 install path/to/your/app.apk

Pushing Files

adb -s device-id-12345.devices.nativebridge.io:7000 push local/path/file.txt /sdcard/

Pulling Files (like screenshots or logs)

adb -s device-id-12345.devices.nativebridge.io:7000 pull /sdcard/screenshots/screen.png ./local/path/

Running Shell Commands

adb -s device-id-12345.devices.nativebridge.io:7000 shell dumpsys battery

Capturing a Screen Recording

adb -s device-id-12345.devices.nativebridge.io:7000 shell screenrecord /sdcard/recording.mp4

(Press Ctrl+C to stop recording, then pull the file to your local machine)

Troubleshooting ADB Connections

Connection Refused or Timeout

If you encounter connection issues:

  1. Ensure your NativeBridge session is active and not timed out
  2. Try restarting ADB with:
    adb kill-server
    adb start-server
    
  3. Attempt the connection again

Device Unauthorized

If your device shows as "unauthorized":

  1. Disconnect the device: adb disconnect <deviceURL>
  2. Restart your NativeBridge session
  3. Reconnect using the new connection details

Port Already in Use

If you see "port already in use" errors:

  1. Check for processes using the port: netstat -ano | findstr :<PORT> (Windows) or lsof -i :<PORT> (macOS/Linux)
  2. Kill the conflicting process and try again

Benefits for Team Collaboration

ADB connectivity in NativeBridge bridges the gap between individual developers and your broader team:

  • Developers can run automated tests against shared devices without needing physical access
  • QA Engineers can verify issues identified in browser sessions using advanced ADB diagnostics
  • DevOps can integrate NativeBridge devices into CI/CD pipelines via ADB connections

Conclusion

By connecting to NativeBridge devices using ADB, you combine the convenience of browser-based testing with the power and flexibility of local development tools. This hybrid approach gives you the best of both worlds: the accessibility of cloud testing with the capabilities of local device testing.

Start integrating NativeBridge's remote devices into your development workflow today, and experience a new level of efficiency in mobile app testing and debugging.


Note: NativeBridge sessions have standard timeout periods. For extended ADB connection sessions, consider upgrading to our Enterprise plan which offers dedicated devices with customizable timeout settings.

Have questions about ADB connectivity with NativeBridge? Contact our support team at [email protected].

Edit Report
Pub: 07 Mar 2025 08:03 UTC
Views: 41