Tutorial: Creating Android TV Apps

google-play-store
Share on Facebook0Share on Google+7Tweet about this on TwitterShare on LinkedIn1

Today’s guest tutorial comes to you courtesy of Greg Pugh, a Corona Ambassador, app developer, video tutorial instructor, children’s book author, and illustrator. Check out Greg’s site at GPAnimations.com for his tutorials and current games.


Corona Labs recently implemented support for the Android TV, a competitor to the Amazon Fire TV and Apple TV. Last year, Ed Maurina released a module that maps the controls to the Amazon Fire TV, so I’ve taken his code and modified it for the Android TV controller. I’m going to show you how you can implement the Android TV game controller button events into your game so you can upload it to the Google Play Store.

First, download the source folder from Dropbox. In this folder, you’ll see a file named RGEasyFTV.lua. This is Ed’s FireTV controller code that I’ve edited. If you open it, you’ll see the code numbers for the Android Game Controller.

Since these are mapped for you here, you’ll only need to reference the buttons by their names in your code (e.g. keyName == 'a').

In the build.settings file, you see that I’ve set supportsTV to be true and isGame to true. The supportsTV line is essential making your app compatible with the Android TV — without this line of code, your app can still be approved for Google Play, but it will not show up as compatible with the customer’s Android TV devices.

In Screen1.lua, you’ll see the following code:

This is the function I use to control the app using the Android TV game controller. You’ll notice that I give the option to either use either the directional pad or the A button. The great part about Ed’s RGEasyFTV.lua file is that it enables you to use your computer’s keyboard to test the app as you’re developing it. So, either the right arrow or the A key on your keyboard can be used until your install it on an actual Android TV.

Two additional pieces of artwork that you’ll need to include for an Android TV app are a 320×180 Banner-xhdpi.png file and a screenshot of how it will look on a TV screen that you’ll add to your app profile on Google Play.

Once your events are coded to game controller input, you can build the app for Google Play:

buildForAndroid

Next, using your developer cable, hook your Android TV to your computer via the USB port and make sure the device is hooked up to a TV and powered on. On my MacBook, I dragged the exported AndroidTVTutorial.apk file into android → sdk → platform-tools.

platformTools

In the Terminal/console, I changed the directory to platform-tools, found my Android TV device, and installed AndroidTVTutorial.apk onto it:

terminal

Now the app is available to play on Android TV:

tv

Once you’ve tested it, you can upload it to Google Play and, if you’ve done everything correctly, your app will now be Android TV compatible!

googlePlay
Share on Facebook0Share on Google+7Tweet about this on TwitterShare on LinkedIn1
Brent

Brent Sorrentino serves as a full-time Developer Evangelist for Corona Labs, assisting developers in the forums, maintaining documentation/guides, and creating samples which highlight core features of Corona SDK.

This entry has 1 replies

  1. Vonn says:

    Wow great, will this work with other countries? Like asian countries?