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 |
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 |
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 |
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.