Connect to Fire TV Through ADB
In the previous topic, you downloaded and built Fire App Builder on your local machine in Android Studio. In this step, you'll connect ADB to a Fire TV and run the app on a Fire TV device. ADB allows you to build and run your app on a Fire TV device.
If you've already set up ADB to connect to a Fire TV device, skip down to Run Fire App Builder on a Fire TV Device.
- Overview
- Step A. Enable Debugging on Amazon Fire TV
- Step B. Set Up Android Debug Bridge
- Step C. Add Android Debug Bridge to Your Path
- Step D: Connect to a Fire TV device through ADB
- Troubleshooting
- Step E: Run Your App
- Troubleshooting
- Next Steps
Overview
You can use Android Debug Bridge (ADB) to connect your development computer to an Amazon Fire TV device or stick for installing, testing, and debugging your apps. Before you use ADB, you must enable debugging on your Fire TV device, and set up ADB on your computer. Follow the steps below.
If you're looking for instructions on connecting to a Fire tablet instead, see Connect to Fire Tablet through ADB.
Here is a video that will explain the basics. For more details, see the rest of the page.
Step A. Enable Debugging on Amazon Fire TV
You must enable both ADB and debugging on your Fire TV device before you can connect to it:
- From the main screen of your Fire TV, select Settings.
- Select Device (or My Fire TV) > Developer Options.
- Turn on ADB Debugging.
- Turn on Apps from Unknown Sources.
- (Optional) If your Fire TV supports USB, and you plan to connect your computer to your Fire TV device using a USB cable, turn on USB Debugging. Note that when USB Debugging is enabled, the USB port is unavailable for other uses such as external storage or input devices. To re-enable the USB port, turn off USB debugging.)
Step B. Set Up Android Debug Bridge
Android Debug Bridge (ADB) is a command-line utility for running and managing Android apps on your device or emulator. ADB is available when you install Android Studio, but Windows users will need to install a special USB driver.
You can check to make sure ADB is installed in Android Studio by going to Tools > SDK Manager. Click the SDK Tools tab. Select and install Android SDK Platform-Tools (if it's not already selected).
No action is required for ADB to work on Mac OS X.
If you're on Windows and want to connect your computer to Fire TV through a USB cable, you need to install a special USB driver to connect your computer to a Fire TV device through ADB. The driver supports all the Fire TV platforms. To install the driver:
- Download the USB file and extract the zip file's contents.
- Double-click the FireDevices_Drivers.
- Complete the installation dialog boxes as prompted.
Step C. Add Android Debug Bridge to Your Path
You need to add ADB to your PATH so you can more easily run adb
commands. (Your PATH is an environment variable used to specify the location of the program's executable. If you don't add ADB to your PATH, running adb
commands will require you to browse to the <Android SDK>/platform-tools
directory to run ADB.)
adb version
from a terminal. If you get back version information, then adb
is in your PATH.To add ADB to your PATH on Mac:
-
Get the path to your Android SDK platform-tools directory:
-
Open Android Studio and click the SDK Manager button . The location to your Android SDK appears near the top next to Android SDK Location. For example:
/Users/<your username>/Library/Android/sdk
If this is your first time opening Android Studio, there isn't an SDK Manager button. Instead, at the Welcome to Android Studio prompt, click Configure > SDK Manager and provide the location to the Android SDK.
- Copy the path to the SDK and paste it somewhere convenient, such as a text editor.
- Add /platform-tools to the end of the path you copied in the previous step. ("platform-tools" is the directory containing the
adb
executable.) - Copy the full path to your clipboard.
-
-
Use the following command to add ADB to your .bash_profile. Replace
<your username>
with your actual username. Also, make sure the path points to your Android SDK.echo 'export PATH=$PATH:/Users/<your username>/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
Your
.bash_profile
file is usually in your user directory, which you can find by typingcd ~
(change to your user directory). Then typels -a
(list all) to show all files, including hidden ones.If the file isn't there, simply create one. You can then type
open .bash_profile
to see the paths listed.After you add this PATH to your bash profile, you should see the following in your
.bash_profile
file:export PATH=$PATH:/Users/johndoe/Library/Android/sdk/platform-tools/
(Only instead of
johndoe
, you will see your own username.) -
Fully restart any terminal sessions, and then type
adb
. If you successfully added ADB to your path, you will see ADB help info rather than "command not found."
To add ADB to your PATH on Windows:
-
Get the path to your Android SDK platform-tools directory:
-
Open Android Studio and click the SDK Manager button .
The location to your Android SDK appears near the top next to Android SDK Location. For example:
C:\Users\<your user name>\AppData\Local\Android\Sdk
If this is your first time opening Android Studio, there isn't an SDK Manager button. Instead, at the Welcome to Android Studio prompt, click Configure > SDK Manager and provide the location to the Android SDK.
- Copy the path to the SDK and paste it somewhere convenient, such as a text editor.
- Add /platform-tools to the end of the path you copied in the previous step. ("platform-tools" is the directory containing the
adb
executable.) - Copy the full path to your clipboard.
-
- Click your computer's search button (next to Start) and type view advanced system settings.
- Click View advanced system settings.
- When the System Settings dialog opens, click the Environment Variables button.
- Under System Variables (the lower pane), select Path and click Edit.
-
Do one of the following:
- On Windows 7 or 8, move your cursor to the farthest position on the right, type
;
and then press Ctrl+V to insert the path to your SDK that you copied earlier. It may look like this:;C:\Users\<your user name>\AppData\Local\Android\Sdk\platform-tools
. Click OK on each of the three open dialog boxes to close them. - On Windows 10, click the New button and add this location.
- On Windows 7 or 8, move your cursor to the farthest position on the right, type
- Restart any terminal sessions, and then type
adb
. If you successfully added ADB to your path, you will see ADB help info rather than "command not found."
Step D: Connect to a Fire TV device through ADB
You can connect to ADB either through the network or through USB. Most Fire TV devices only allow network connections, so this is the more common approach.
With this option, you connect using either a wired Ethernet or wireless network connection. Both your computer and the Fire TV device must be on the same network for a network ADB connection to work. All Fire TV devices offer the option to connect wirelessly.
- Make sure your Fire TV device and your computer are on the same network. You can use either a wifi network or a wired network. You can check the network your Fire TV is on by going to Settings > Network.
-
Now get the IP address of your network. From Settings, go to Device (or My Fire TV) > About > Network. Make a note of the IP address listed on this screen.
Warning: You do not get the IP address from the Settings > Network screen. There's another Network screen under Settings > Device > About > Network that shows the IP address. Don't confuse the two network screens. -
Open a terminal window.
On a Mac, you can open Terminal by pressing Cmd + spacebar and then typing Terminal. On Windows, you open the Command Prompt usually by typing cmd in your program search. (The exact steps vary based on your Windows version.)
-
Run the following command, where
<ipaddress>
is the IP address of the Fire TV device noted in the previous section. The<port>
can be any number within the 5555 to 5585 range.adb connect <ipaddress>:<port>
For example:
adb connect 10.49.172.51:5555
Note: Make sure you added ADB to your PATH, as described in Add Android Debug Bridge to Your Path. Otherwise you will need tocd
to the platform-tools directory first and use./adb
on a Mac oradb
on Windows to runadb
commands.The first time you run
adb connect
, Fire TV will show a screen that says "Allow USB debugging?"If you don't allow USB debugging, Fire TV won't authorize the ADB connection. Select the Always allow from this computer check box, and then click OK.
If the ADB connection was successful, ADB responds with the message:
connected to <ipaddress>:5555
If you need to stop or restart the server, use these ADB commands:
adb kill-server adb start-server
-
Verify that the Fire TV device appears in the list of devices:
adb devices
ADB responds with a message like this:
List of devices attached 10.49.172.51:5555 device
(where
10.49.172.51
is your IP address.)
If the serial number does not appear after running adb devices
, or you get a message saying unable to connect
, you will need to troubleshoot ADB.
adb connect <ipaddress>
command.To connect your computer to a Fire TV Stick through USB, connect one end of the USB cable to the Fire TV Stick (that's plugged into your computer monitor via HDMI) and the other end to your computer. This also works on the Fire TV (Gen 1 or 2) through USB, but you need an A-to-A USB cable. If your Fire TV device doesn't offer a USB cable port, use the Network Connect option instead.
- If you're on Windows, install the USB driver as described in Set Up Android Debug Bridge.
- Turn on USB debugging. See the section on Enable Debugging on Amazon Fire TV. (Go to Settings. Then select Device (or My Fire TV) > Developer Options. Then turn on USB Debugging.)
- Connect your Fire TV to a USB port on your computer.
-
Run the following commands:
adb kill-server adb start-server adb devices
After the last command, ADB responds with the following message, where <serialno>
is the serial number of the device:
List of devices attached
<serialno> device
If you run into issues connecting to ADB, see these troubleshooting tips.
Troubleshooting
If you receive a message such as the following:
unable to connect to 192.168.0.6:5555: Operation timed out
or
error: device offline
try doing the following to resolve the issue:
- Make sure both Fire TV and your computer are using the same network.
- When connecting wireless with
adb connect <ipaddress>
, make sure you're typing the IP address correctly, with all the required dots.
- Close Android Studio and any other emulators or USB cable connections.
- Stop (
adb kill-server
) and restart (adb start-server
) the server. - Restart Fire TV (Settings > Device [or System] > Restart).
- Restart your router.
- See if another service is blocking ADB.
- Read through the Android Debug Bridge (ADB) on Android
- Search online for the error message you're seeing.
Step E: Run Your App
After you have connected your computer to your Fire TV device through ADB, you can build and run your app on the Fire TV device.
- Connect your computer to your Fire TV device using ADB, as described in the previous sections.
- In Android Studio, click the Run 'app' button .
-
In the Select Deployment Target dialog box, select Amazon, and then click OK.
In the Select Deployment Target dialog box, AFTS
refers to Amazon Fire TV (Generation 2). If you have another device, the abbreviation and API level will differ. You can see the specific build models for each Fire TV device in Identifying Fire TV Devices.
When the app builds successfully, your Fire TV device will load the application.
Note that ADB builds the app on your connected device in a temporary folder. When you disconnect your device, the app will no longer be available on the Fire TV. If you want to permanently install the app onto your Fire TV, you will need to sideload the app onto your device. See Installing and Running Your App.
If you close the app on your Fire TV, you can relaunch it using the Fire TV UI by going to Settings > Applications > Manage Installed Applications > Fire App Builder with your remote control.
If you run into trouble running your app, see the troubleshooting information below.
Troubleshooting
This section lists some common issues and steps for troubleshooting.
Issues from Package Naming Conflicts: If you try to run the app but get an error on your device, you may have a package name conflict. If a published version of your app is already installed on your Fire TV device, and you try to sideload or run a development version of the app (with the same package name) through Android Studio, you'll see an error message.
Uninstall the published app from your device before running the development version. You can uninstall a published app from Fire TV by going to Settings > Applications > Manage Installed Applications. Select your app, and then select Uninstall twice.
Missing port in specification
If you get an error that says something like missing port in specification: tcp:10.12.345.67
, add in the port (5555
) at the end when you connect: adb connect 10.12.345.67:5555
. See this Stack Overflow thread for more details.
Next Steps
Go to the next topic, Take an App Tour, to become more familiar with the setup, features, activities, and screens in Fire App Builder.
Last updated: Jun 28, 2022