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:
- Go to Tools > Android > AVD Manager, or click the AVD Manager button on the top navigation bar.
Click the + Create Virtual Device button.Note: You can select one of the default TV profiles, or you can customize the settings by following the steps below. If you select a default TV profile, skip ahead to step 12 where you select a system image.
- In the Category column, select TV.
- Click the New Hardware Profile button.
- In the Device Name, type something like fire_tv_emulator. (Avoid using parentheses in the name, as this may cause errors.)
- For the Device Type, select Android TV.
- For the Screen size, type the screen size you want (for example, 40).
- For the Resolution, type the resolution you want (for example, 1280 x 720).
- For the Supported device states, select only Landscape (clear the Portrait check box).
- Click Finish.
- In the "Choose a device definition" dialog box, select the emulator you just created and click Next.
- 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.)
- 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 . 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.