Developer Console

Use an Android TV Emulator to Run Your App

When you develop your app with Fire App Builder, you should use an actual Fire TV device to test your app. See Connecting to Fire TV Through ADB for details. However, if you're in a situation where you can only use an emulator, you can get by if you accept some limitations with the emulator. The emulator will work, but you can't click the media player buttons with your mouse.

Mouse clicks generate motion events, which aren't supported by media played in Fire App Builder (you'll see an error in logcat that says "java.lang.ClassCastException: android.view.MotionEvent cannot be cast to android.view.KeyEvent"). As a result, the app will crash on the emulator if you use your mouse to click the media player's buttons.

Instead of using your mouse on the media playback screen, to return to the previous screen after playing media, click the Back button on the right of the emulator (as indicated by the arrow in the following screenshot).

Don't click the media player's buttons with your mouse. Outside of media playback, you can use your mouse to click wherever you want.

To configure an emulator:

When you configure the Android TV emulator, you must select at least API Level 23 or 24. You have flexibility with the other settings (resolution, size, and so on). (If you choose API Level 24, you'll be prompted to install Instant Run, which is a requirement for this API level.)

To set up an Android TV emulator for your app:

  1. Go to Tools > Android > AVD Manager, or click the AVD Manager button on the top navigation bar.
  2. Click the + Create Virtual Device button.

  3. In the Category column, select TV.
  4. Click the New Hardware Profile button.
  5. In the Device Name, type something like fire_tv_emulator. (Avoid using parentheses in the name, as this may cause errors.)
  6. For the Device Type, select Android TV.
  7. For the Screen size, type the screen size you want (for example, 40).
  8. For the Resolution, type the resolution you want (for example, 1280 x 720).
  9. For the Supported device states, select only Landscape (clear the Portrait check box).
  10. Click Finish.
  11. In the "Choose a device definition" dialog box, select the emulator you just created and click Next.
  12. In the Release Name column, select at least Marshmallow API Level 23 or higher. If you haven't downloaded this system image yet, click Download to download it. (If you select API Level 22 or lower, media playback will fail in the emulator.)
  13. Click Next and then click Finish.

The emulator is now listed as an option in your virtual devices.

Run your app by clicking the Run 'app' button Run 'app' button . Select the virtual device you created:

Now you can use the emulator as usual. Just be careful when you play media. When you play media, don't click the buttons on the media player with your mouse. Instead, either use your keys or use the buttons to the right of the emulator as shown in the earlier screenshot.


Last updated: Aug 22, 2017