If you are an Android developer and want to get started developing for Google TV you came to the right place. I'm getting started on Google TV right now I want to share codes with you. So, let's get start.
Google TV limitations:
The thirst thing to keep in mind about Google TV app is that it's an Android app yet! However, we need consider some little things:
- Google TV is NOT a touch device;
- Google TV is large screen device;
- Google TV doesn't have sensors like accelerometer and compass;
- Google TV doesn't support camera, GPS, Bluetooth, microphone;
- Google TV doesn't support NDK;
As we can see, we are talking about a special kind of Android device and so we need consider some special features for that can work. To know the complete list of unsupported features of Google TV see
the official report.
After remember that Google TV is a kind of special device we need to know that it needs a specific Android SDK version to work. Until today, the unique version of Android API compatible with Google TV is the 12 (Android 3.1). Another thing about developing for Google TV is that besides the API, it's necessary
install the Google TV Addon (which is available on
Android SDK Manager as well), what can be a problem is: this runs just on Linux!
So, if as me you have no problem about work with Linux (or even prefer it) neither about the Google TV hardware limitations, congratulations, you are able to keeping forward! =)
How to configure the Android Virtual Device to emulate the Google TV:
The process to emulate Google TV is the same as any Android device, but you have to select the
Google TV Addon option on the
Target field of the
Android Virtual Device edit screen from
Android Virtual Device Manager and a
tvdpi or
xhdpi device on
Device field.
Know more about Google TV AVDs.
![Android Virtual Device edit screen Android Virtual Device edit screen](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNKRl5pxK_qhW2EV9p1GiFNb95JwzWs-qV71gVv134T7q3f2v1PEycVxmrTWsAzSbNvnA_5dm3T-LYvWovh1XiKPpHroeaF6G2B4Gs2GiYwpfGm49XP9p1yXm4Rdrjf9A-s4hhltbv6zzF/s400/AVD-googleTV.png) |
Android Virtual Device edit screen |
After create your AVD following the specification of the image above, you'll need to do some manual adjusts on that. So, open the
~/.android/avd/GoogleTV.avd/config.ini file and overwrite the follow lines:
skin.name=720p
skin.path=add-ons/addon-google_tv_addon-google-12/skins/720p
skin.dynamic=no
Now you'd be able to run the Google TV emulation. Yet if you get the follow message error, that means you can't read or write in
/dev/kvm what is required for that the emulator can run.
Failed to load libGL.so
ioctl(KVM_CREATE_VM) failed: Interrupted system call
error libGL.so: cannot open shared object file: No such file or directory
ko:failed to initialize KVM
Failed to load libGL.so
error libGL.so: cannot open shared object file: No such file or directory
To correct that, open your Linux terminal and do:
sudo chmod a+rw /dev/kvm
So now you can start developing you first Google TV application as well.
![Google TV emulator booting Google TV emulator booting](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZfC2v96lD6EzF7gF1l9PJE1G5SDJ_5lpeJ_Jyy-EX0vfx5zrzHHZAeIvjem108SVtdaI6ZHYU7EZS19ERaUJQLuuB7jksv1N9D9A4h30Re71-kIR0ps0Sdwum4JBF46TwNYGYriwv7JUZ/s400/googletv-emulator.png) |
Google TV emulator booting |
Some important notes before starting coding:
I'm assuming that you are already an Android developer, so I'll not show you how to start a new Android project. However, it's important remember that the Android system assumes that all application require a touchscreen, so we need to say the oppose for it. For that we can put the follow code in the
AndroidManifest.xml file:
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false"/>
Another important note is that if you are doing an application to runs both on Google TV and smartphones or tablets you can use
layout-large-notouch for layouts and
drawable-land-xhdpi (1080p) or
drawable-land-tvdpi (720p) for drawables to target Google TV. Even you can determine if the app is running on Google TV by testing:
if (getPackageManager().hasSystemFeature("com.google.android.tv")) {
Log.d("TV Test", "Running on Google TV!");
}
![A very simple test app running in the emulator A very simple test app running in the emulator](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimnYJX27iTj1c8OMbw2jGxen2W17Aqr-7wotKE_-B3q10zQs8z_u6qLPxnahG4Jv_hyHqu27_eex1QDyna5b-6GhDnj89Mf6aUaxpVE2dU0VbHyV7b3XAegsaO-VGt4WL6SJvgli7F32NF/s400/simple-app-example-googletv.png) |
A very simple test app running in the emulator |
Hope this help you, til next code!
The follows links are consulted to write this post:
https://developers.google.com/tv/
http://oncelinux.blogspot.com.br/2013/01/googletv-emulator-hang-on-logo-screen.html
I would like to specially thanks to +David Carver who helped me a lot with some emulator's problems.