Part 1: Deploy a “Hello World” Media Streaming App on Fire TV in a Few Minutes
Android is no longer just for Mobile devices. Even if it started as an OS designed for smartphones, it evolved during time. In 2011 with Android 3.0 Honeycomb, specifically designed for tablets, Android scaled up to bigger screens, and this changed the way users engaged with mobile devices. Recently, Android scaled up to an ever bigger screen: the TV.
All of a sudden, Android developers can start thinking about building native Android apps for a new and exciting use case, the 10-foot experience, where users sit down, relax and engage with content specifically designed for their TV.
Amazon Fire TV and Fire TV Stick are Android devices
Amazon Fire OS, which animates all the most recent Amazon devices like Fire tablets, Amazon Fire TV and Amazon Fire TV Stick, is based on Android 5.0 Lollipop. This means that Fire OS is capable of running full-fledged Android apps: 85% of Android apps submitted to the Amazon Appstore just work! If your app relies on the Android framework APIs and related support libraries, there’s a high chance it can run on Fire OS. You can test your APK on our online App Testing Service and discover in 90 seconds if your app is compatible with Fire OS! When it comes to Fire TV, we wanted to make life of developers easy. That’s the reason we decided to fully support the Android Leanback Support library. This make extremely easy for Android developers to deploy native media streaming apps for TV.
Let’s discover how.
Creating a Media Streaming App Project
When it comes to Media Streaming devices like Fire TV, one of the most common use case is to stream video content, like movies, TV Series or video sharing channels like YouTube. The Android Leanback Support Library contains all the main components and widgets to create an efficient and good-looking Media Streaming Android App. Android Studio provides an easy way to deploy a Leanback-enabled Android TV sample project. The great news is that this sample project works out of the box on Fire TV!
Step 0 – Enable Developer Options and ADB over WiFi on Fire TV
Before creating our project and deploying to the Amazon Fire TV, we need to enable Developer Options and Debug ADB on our Fire TV. To do this, navigate to the Settings of the Fire TV and select System->Developer Options.
Now, we need to enable Developer Options and ADB. The best way of developing on Amazon Fire TV is to connect via WiFi to the device. This way we might even sit down on a couch and develop in front of our TV and start experiencing our TV app like our users will do! To enable ADB, just set ADB Debugging to ON.
At this point, our Amazon Fire TV is ready to receive Android debug apps. The last thing we need is the IP ADDRESS of our Fire TV. We will use it to connect our development environment to the Fire TV over the network. To retrieve it, just go to Settings->System->About->Network and copy the IP Address.
On our computer connected to the same WiFi Network as the Amazon Fire TV, we can now open up our terminal and run the command
adb connect <ip-address>
where <ip-address> needs to be substituted with the Fire TV IP Address we have previously copied. Now we are connected to the Amazon Fire TV and we are good to go to deploy our first media streaming app!
Step 1 – Create the Project through Android Studio Project Wizard
The first step is to create a new Android project through the Android Studio Project Wizard.
We select TV as form factor for our app, and we set Minimum SDK to API 21: Android 5.0 Lollipop. This is because, as we said earlier, Fire OS is based on Android 5.0.
In the Next Step, we select to add an Android TV Activity.
We then can follow the normal final steps to finalize our TV project. When you click Finish at the end of the final step, Android Studio will generate a project which contains a full-fledged Leanback-enabled TV App!
Step 2 – Run your first Amazon Fire TV App
At this point you can already run your first Amazon Fire TV app! This is because the app that has been created by the Android Studio Wizard contains all the main components of a complete media streaming app. Just click the run button on Android Studio and if you are connected to your Fire TV, the app will appear on screen. The interface will look very similar to this one:
You will be able to navigate the content and the categories, see details of the content and launch media streaming. The application already contains a lot of additional features like animations, fragment support and memory optimisation for loading media streaming content. This could be an easy boilerplate for creating a much more complex and rich Fire TV App.
In Part 2 of This Series: Understanding Components of a Leanback-Enabled Amazon Fire TV App
This is the just first step in creating a complete Amazon Fire TV App. Before jumping in on modifying and personalizing this “hello world” app project, we need to understand what the main components of this app are so we can edit it appropriately.
In the next parts of this Series we’ll analyse the main components like the BrowseFragment and DetailsFragment and will explain how to play and stream media content.
Mario Viviani (@mariuxtheone)
Don't miss the rest of the Developing for the Living Room: How to Build an Android App for Fire TV blog series!