Gracias por tu visita. Esta página solo está disponible en inglés.

Set Up the Sample Fire TV App with Video Skill

A sample Fire TV app that incorporates a video skill is available, in case you want to explore it. The sample app (optional in the integration step here) will allow you to see a directive pushed to the app. Although the app is simple, it can reduce some of the integration steps to allow you a better sense of the larger integration process.

Overview

The sample Fire TV app incorporates a working video skill. The app shows ADM and the Alexa Client Library integrated, and once configured, plays up a video when you ask Alexa for the video by title. The sample app is a fork from Fire App Builder, which is a Java-based Android toolkit for building Fire TV apps.

Using this sample app mostly eliminates Step 3: Integrate the Alexa Client Library and Step 4: Integrate Amazon Device Messaging (ADM) because the code is already integrated into the sample app. You'll still need to work through the rest of the documentation here to set up the sample app.

Mainly, the sample app will allow you to see a directive pushed to the app. This preview can give you more of a sense of how the video skill will interact with your app. The sample app does not show logic about how to handle the directives to perform specific actions in the app. You'll need to work out much of the logic on your own based on your own unique code.

Additionally, this sample app is meant as a companion to the documentation, not as a starting point or template for your own app. Almost every video partner that integrates a video skill already has a custom-developed app already. The sample app simply provides some context for some of the integration instructions.

Prerequisites

To work with the sample app, you will need the Java Developer Kit (JDK) and Android Studio. Experienced Android developers likely already have this set up. If so, you can jump down to Step A: Download Sample Fire TV App.

Java Development Kit

You need the 1.8 version of Java Development Kit (JDK) or greater from Oracle. The JDK is used to compile Java apps on your machine. First, check to see if you already have the JDK:

  1. Open Terminal or a command prompt.
  2. Type java -version. If you have the JDK, the response should be something like this:

    java version "1.8.0_121"
    Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode
    

    On Windows you can also manually look in a directory such as C:\Program Files\Java\jdk1.8.0\ to see if the JDK is there.

  3. If you don't have the JDK, download the appropriate version of the JDK Installer for your machine from Java SE Development Kit Downloads and run it. For more details, see the following:

Android Studio

To work with the sample app, you need to install Android Studio, the official IDE for Android projects. See Getting Started with Android Studio and Install Android Studio for information about setting up the Android Studio development environment on your machine.

The sample app requires you to have certain SDK tools and APIs installed with Android Studio. Selecting these tools from the Standalone SDK Manager ahead of time isn't necessary. When you open the sample app project (as described in the next section, Open the Sample App), Android Studio will prompt you to install any build tools or APIs that you're missing.

Step A: Download Sample Fire TV App

To download the sample app:

  1. Go to https://github.com/amzn/sample-fire-tv-app-video-skill.
  2. Click Clone or download. Then click Download ZIP.
  3. Save the zip file to a convenient location and then unzip it.

Step B: Open the Sample App in Android Studio

Open the project in Android Studio and build the app:

  1. Start Android Studio.
  2. At the Welcome screen, click Open an existing Android Studio project.
  3. Browse to the directory where you downloaded the sample-alexa-firetv-app project. Inside the project folder, select the Application folder, and then click OK.

    Gradle starts building the project.

    Depending on the latest release of Gradle, you may be prompted to update Gradle. If prompted, click Don't remind me again for this project.

    The first time you open the project, it can take anywhere from 20-40 minutes for Gradle to build the project, depending on the assets Gradle needs to download as well as your network and processor speed. Subsequent times should take about a minute or less.If Android Studio is missing any needed libraries or files, you might see messages such as the following:

    If you see these messages, click these links to install the missing tools. Simply keep opening the project and installing any missing tools as prompted until Android Studio no longer complains.

    If you run into build failures, you can try cleaning and rebuilding the project (Build > Clean Project or Build > Rebuild Project).

  4. Open the Gradle Console by clicking the Build button in Android Studio's footer so you can monitor the progress of the Gradle Build. This will let you know if the build succeeds or if Android Studio requires other downloads. Wait until Gradle finishes building.

    When the build finishes, you should see a message in the Gradle Console that says Gradle build finished. When Gradle finishes building the project, Android Studio will show the following directories in the Android view:

    Android Studio directories with Alexa Client Library included

    Notice that one of the directories is AlexaClientLib, which includes the Alexa Client Library. This directory is not included in the default Fire App Builder project.

    When Android opens the project, by default the Android view is shown (circled in red in the previous screenshot), and the "Application" folder is simply referred to as "app."

Step C: Customize the Package Name in the Sample App

You need to change the package name in the sample app. Package names must be unique in the Appstore, and later configurations with security profiles and API keys will require a unique package name. The following code samples show the package name that needs customization in bright red. To customize the package name:

  1. Make sure you're in the Android View (as described in the previous section).
  2. Go to app > manifests and open the AndroidManifest.xml file. Update the package name com.fireappbuilder.android.calypsovsk name to a unique package name, such as com.fireappbuilder.android.mycompany:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.fireappbuilder.android.calypsovsk">
    

    The sample app doesn't have any classes in the com.fireappbuilder.android.calypsovsk package.

  3. Expand Gradle Scripts in the sidebar and open the build.gradle (Module: app) file. Update the applicationId property to match your package name. For example:

    defaultConfig {
        applicationId "com.fireappbuilder.android.calypsovsk"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 10
        versionName "1.0.7"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    
  4. Go to TVUIComponent > manifests and open the AndroidManifest.xml file. Change every instance of the package name to your unique package name. There are several instances to change:

    <permission
        android:name="com.fireappbuilder.android.calypsovsk.RECEIVE_ADM_MESSAGE"
        android:protectionLevel="signature" />
    
    <uses-permission android:name="com.fireappbuilder.android.calypsovsk.RECEIVE_ADM_MESSAGE" />
    
    <intent-filter>
    <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
    <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
    <category android:name="com.fireappbuilder.android.calypsovsk" />
    
  5. Go to ContentBrowser> res > values and open custom.xml. Change the package name in the following line:

    <!--Your package name, should be same as in AndroidManifest--&>
    <string name="launcher_integration_intent_package_value">com.fireappbuilder.android.calypsovsk</string>
    
  6. When you make changes to Gradle files, you might be prompted to synchronize Gradle with your project. If prompted, click the Sync Now link in the upper-right corner.
  7. Go to Build > Rebuild Project to clean up any artifacts from the previous app and then rebuild your project.

    With this sample app, don't worry about warnings such as "Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'." The app will still build. These updates will be made in a future version of this sample app.

Identifying Sample App Instructions

The documentation calls out specific info along the way for working with the sample app. Often the documentation will put information related to the sample app in a callout like this:

Sample App Instructions

Instructions for working with the sample app often appear formatted like this. Unless you see this callout, continue through the normal documentation steps. The callouts will either instruct you to continue through the regular steps or skip certain ones. Sometimes, the instructions in the callout will point to a section labeled "Sample App" at the end of the topic.

Next Steps

Now that you have the sample app set up, go to Step 1: Create Video Skill and Lambda.