Connect to adb
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.
Step 1. 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 > 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. 9To re-enable the USB port, turn off USB debugging.)
Step 2. 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).
Mac OS X
No action is required for adb to work on Mac OS X.
Windows
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.
Note: The USB driver is only certified through Windows 8.1. If you're on Windows 10, you will need to explicitly accept that you are installing from an "un-certified source."
Step 3. Add Android Debug Bridge to Your Path
You need to add adb to your PATH so you can more easily execute 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.)
Tip: You can check whether adb is already added to your PATH by typing
adb version
from a terminal. If you get back version information, then adb
is in your PATH.Mac OS X
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, replacing
/Users/<your username>/Library/Android/sdk/platform-tools/
with your path to your Android SDK.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 typeopen .bash_profile
to see the paths listed. One of the lines should be something like this:export PATH=$PATH:/Users/<your username>/Library/Android/sdk/platform-tools/
. - 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."
Windows
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\platform-tools
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 Start and type view advanced system settings in the search box.
- 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 4: Options for Connecting adb
You can use adb to connect the Fire TV or Fire TV stick to your computer in two ways:
- Connect adb Through the Network. 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.
- Connect adb Through USB. This option is available only for Fire TV devices that have a USB port, such as Fire TV (Gen 1 and 2). For these devices, you can use an A-to-A USB cable to establish a direct USB connection.
Connect adb Through the Network
You need the IP address of your Fire TV device on your network to connect adb to it.
- 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 > About > Network. Make a note of the IP address listed on this screen.Warning: This is somewhat unintuitive, but 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 commands, where
<ipaddress>
is the IP address of the Fire TV device noted in the previous section: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.If the connection was successful, adb responds with the message: - Verify that the Fire TV device appears in the list of devices:adb responds with the message:
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.
Tip: You don't always need to kill and start the server with adb. Usually you can just run the
adb connect <ipaddress>
command.Connect adb Through USB
To connect your computer to Fire TV (Gen 1 or 2) through USB, you need an A-to-A USB cable. Note that you must have a Fire TV Gen 1 or Gen 2 device, not a Fire TV Stick, Fire TV (Gen 3), or Fire TV Edition, because only Fire TV (Gen 1 and Gen 2) have a port for the 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 > Developer Options. Then turn on USB Debugging.
- Connect your Fire TV to a USB port on your computer.
- Run the following commands:
After the last command, adb responds with the following message, where
<serialno>
is the serial number of the device:
After adb connects your computer to your Fire TV device, when you open Android Studio and click the Run App button, you'll be prompted with a dialog box like this:
In this example, "Amazon AFTS" refers to Fire TV (Generation 2).
Conflicts with Existing Apps
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.
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. In Android Studio, click the Run App button .
Troubleshooting
If you receive a message such as the following:
or
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.
- Kill (
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.
Run Fire App Builder on a 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.
Tip: If you don't see the Amazon option when you build your app in Android Studio, you haven't connected your computer to the Fire TV device through adb. If you don't have a Fire TV, there is limited support for using an emulator.
When the app builds successfully, your Fire TV device will load the application. See Take an App Tour provides a screen-by-screen walkthrough of the app.
If you run into build failures, you can try cleaning and rebuilding the project (Build > Clean Project or Build > Rebuild Project).
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.
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.
No comments:
Post a Comment
Thank you for your comment!