The tvlabs connect command uses the Android SDK to connect with Android TV devices on the TV Labs platform as if they were in front of you. This includes both Google TV and Fire TV platforms.
Prerequisites
Before starting, please ensure that Android Studio, and adb command line tool is installed on your system and available in your PATH.
You may install adb through the Android Studio UI. Go to "Tools" > "SDK Manager", and find the "SDK Tools" tab. Ensure that "Android SDK Command-line Tools" and "Android SDK Platform-Tools" are installed.

Connecting
After Android Studio and adb are installed, start an Android TV session on TV Labs and run tvlabs connect.

Once tvlabs connect has successfully created a vendor connection, run adb devices to check that the device is connected properly. The Android TV device should appear in the list of devices as <device-ip>:5555.

Port Mapping
The port mapping when tvlabs connect is running and connected to a Android TV session is as follows:
- Local port 5037 to adb server port 5037 (Android Debug Bridge interface)
- Local port 6466 to Android TV device port 6466 (Remote Control)
- Local port 6467 to Android TV device port 6467 (Remote Control Pairing)
Installing
Once connected, you may interact with the Android TV device as if it were on your local network.
Build your application apk locally, and push it to the TV Labs device by running adb install path/to/apk/file.apk to install the application.
Replace the /path/to/apk/file.apk portion with the path to your application apk file.
After the application is installed, it can be launched using adb shell am start -n com.example.your.application/.MainActivity.
Replace the com.example.your.application/.MainActivity portion with the ID of your application, and the main activity name.
Troubleshooting
If you cannot connect to the device because of the error failed to setup port forwarding: failed to forward port 5037 to 5037: port is already in use, please ensure that your local adb server is not running. You can stop the adb server by running adb kill-server.
If application installation fails, please ensure that the device storage is not full.
If tvlabs connect fails on the vendor connection, ensure that development mode is enabled on the device.
If when you are first connecting a popup to allow USB debugging appears, please click allow. If this is not allowed, then the device will be unauthorized in the adb devices list. Select "Allow" on the popup about USB debugging that appears on the device to authorize it.

If tvlabs connect still cannot make a connection after trying these steps, please contact TV Labs for support.
