developing for android tv and the nexus player - mihai risca & alexander weggerle, intel
TRANSCRIPT
Developing for Android TVMihai Risca, Application Engineer
Alexander Weggerle, Technical Consulting Engineer
2
Agenda
• What are Android TV and the Nexus Player
• How to create/adapt an Android application for Android TV
• How to publish an Android TV application
• Optimizing applications for the Nexus Player
• Q&A
4
Android TV
• It’s Android
• it’s also Chromecast
• Apps (streaming and others)
• Games (casual and more)
• AOSP compliant
• Leanback Launcher, Google Apps and Play Store
5
Nexus Player
• First Android TV device / The only Nexus• Quad-Core Intel Silvermont CPU @1.83Ghz • PowerVR™ Series 6 G6430 GPU• 64bit, OpenGL ES 3.1• WiFi 802.11ac*• 1GB ram, 8GB flash, USB-OTG • 99$• Gamepad sold separately**
* Ethernet can be added using standard USB adapters** Android TV supports almost any USB/Bluetooth HID Gamepads
8
Developing for Android TV
Create a new Android application or add support to an existing one by:
1. Adding/reusing a TV-compatible activity that will receive the leanback intent
2. Integrating TV-specific assets
3. Supporting non-touchscreen input
4. Adapting the UX of your app to Android TV
All this should be done to an existing Android app, so you can support phones, tablets, and TVs from your same source code and APK.
You can still choose to create a TV-specific APK and upload it as a new application or as an alternative APK using Play Store “multiple APKs” feature.
9
1. The Leanback Intent
<activity android:name=".TvMainActivity“ >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LEANBACK_LAUNCHER"
/>
</intent-filter>
</activity>
10
2. The Banner
<activity or <application
…
android:banner="@drawable/ic_banner"
…
>
• Name of your application
• No transparency
• Size:160x90dp -> 320x180px image to put inside drawable-xhdpi folder.
11
3. Supporting non-touchscreen input
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
Adjust D-PAD navigation:
android:focusable="true", <requestFocus /> / .requestFocus()
android:nextFocusDown="@+id/whatever1"
android:nextFocusUp="@id/whatever2"
For custom Views: KeyEvent.KEYCODE_DPAD_(UP|DOWN|LEFT|RIGHT)
12
4. Adapting the UX
Start from android:Theme.NoTitleBar
Or Theme.Leanback from the Leanback support library:compile "com.android.support:leanback-v17:21.0.+“
Add overscan margins to your views: (Leanback Views and Fragments already have these)
android:layout_marginTop="27dp"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp"
android:layout_marginBottom="27dp"
Note: Leanback support library requires API 17 but you can still support lower API levels from your app:• Use Theme.Leanback from –v21 resource folders, use Leanback classes only from your
TV-part. • Set <uses-sdk tools:overrideLibrary="android.support.v17.leanback" />
13
Going further
Using ready-to-use elements from the Leanback Support Library
Supporting multiple controllers
Integrating the recommendation system
Integrating the search system
15
Play Store additional requirements
Is your app a Game ?
<android:isGame="true">
Supporting Gamepads ?
<uses-feature android:name="android.hardware.gamepad“ android:required="false" />
Supporting only Android TV ?
<uses-feature android:name="android.software.leanback" android:required="true" />
16
A classic trap: implicitly required featuresHaving portrait activities declared inside your app ? Need to specify that your app can be used on hardware that doesn’t support “portrait” mode:
<uses-feature android:name="android.hardware.screen.portrait“ android:required="false" />
Use of certain permissions also implicitly requires hardware features that aren’t available:
• android.hardware.location implied by android.permission.ACCESS_FINE_LOCATION
• android.hardware.camera.autofocus and android.hardware.camera implied by android.permission.CAMERA
• android.hardware.microphone implied by android.permission.RECORD_AUDIO
• android.hardware.telephony implied by many telephony-specific permissions
17
Submitting your application
1. Check you’re compliant with all the guidelines
2. Upload your APK
3. Upload your banner and a screenshot
4. Opt-in for distribution to the Play Store on Android TV
19
Android* Devices with Intel Inside(Some of them – there are more than hundred, not all could be listed here)
Motorola* RAZR i
ZTE* Grand X IN
Lava* XoloX900
Megafon* Mint
Lenovo* K800
Orange* San Diego
2012, 2013…
Lenovo* K900 ASUS Fonepad™ Note FHD - 6”
ZTE* Geek Samsung* Galaxy™ Tab 3 10.1”
2014… Asus* Zenfones 4/5/6 ASUS* Transformer Pad TF103CG/TF303CL
Dell* Venue 8 7000
Intel® Yolo Acer* Liquid C1Etisalat E-20*
ASUS* MeMO Pad FHD 10
ASUS* Fonepad™ 7” Dell* Venue 7/8
KD InteractiveKurio Tablet Toshiba
Excite GoAcer* Iconia Tab 8
/ One 8 Nexus PlayerLenovo* S8Asus* MemoPad 7/8
Asus* FonePad 7/8Lenovo Yoga Tab 2 8/10/13
Tesco Hudl 2
20
These devices are all fully compatible with Android* ARM* ecosystem
Android* SDK apps− These will directly work. We’re optimizing the
Runtimes for Intel® platforms.
Android* NDK apps− Most will run without any recompilation on consumer platforms.
− Android NDK provides an x86 toolchain since 2011
− A simple recompile using the Android NDK yields the best performance
− If there is specific processor dependent code, porting may be necessary
Android Runtime
Core Libraries
DVM / ART
21
3rd party libraries/engines x86 support• Game engines/libraries with x86 support:
• Havok Anarchy SDK: android x86 target available
• Unreal Engine 3: android x86 target available
• Marmalade: android x86 target available
• NexPlayer SDK: x86 supported by default in latest releases
• Cocos2Dx: set APP_ABI in Application.mk
• FMOD: x86 lib already included, set ABIs in Application.mk
• AppGameKit: x86 lib included, set ABIs in Application.mk
• libgdx: x86 supported by default in latest releases
• AppPortable: x86 support now available
• Adobe Air: x86 support now available
• Unity: x86 support available in 5.0 beta, soon-to-be released for earlier versions
• …
22
Include all ABIs by setting APP_ABI to all in jni/Application.mk:
APP_ABI=all
The NDK will generate optimized code for all target ABIs
You can also pass APP_ABI variable to ndk-build, and specify each ABI:
ndk-build APP_ABI=x86 #all32 and all64 are also possible values.
Configuring NDK Target ABIs
Build ARM64 libs
Build x86_64 libs
Build mips64 libs
Build ARMv7a libs
Build ARMv5 libs
Build x86 libs
Build mips libs
23
“Fat” APKs
By default, an APK contains libraries for every supported ABIs.
Install lib/armeabi-v7a libs
Install lib/x86 libs
Install lib/x86_64 libraries
libs/x86
libs/x86_64
APK file
…
Libs for the selected ABI are installed, the others remain inside the downloaded APK
… … …
libs/armeabi-v7a
24
Multiple APKs
Google Play* supports multiple APKs for the same application.What compatible APK will be chosen for a device entirely depends on the android:versionCode
If you have multiple APKs for multiple ABIs, best is to simply prefix your current version code with a digit representing the ABI:
2310 3310 6310 7310
You can have more options for multiple APKs, here is a convention that will work if you’re using all of these:
x86ARMv7 ARM64 X86_64
25
Multiple APKs – clean solution with gradlesplits {
abi {
enable true
reset()
include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
universalApk true
}
}
// map for the version code
project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5,
'mips64': 6, 'x86': 8, 'x86_64': 9]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
project.ext.versionCodes.get(output.abiFilter, 0) * 1000000 +
android.defaultConfig.versionCode
}
}
28
Intel x86 Emulator
Accelerator
Intel x86 Atom System Image
Faster Android* Emulation on Intel® Architecture Based Host PC
• Pre-built Intel® Atom™ Processor Images available through the Android* SDK manager
• Intel® Hardware Accelerated Execution Manager (Intel® HAXM) for Mac and Windows uses Intel® Virtualization Technology (Intel® VT) to accelerate Android emulator
• Intel® VT is already supported in Linux* by kvmkernel driver
29
Intel INDE
29
Increasing productivity at every step along the development chain
A productivity tool built with today’s developer in mind.
IDE support: Eclipse*, Microsoft Visual Studio*
Host support: Microsoft Windows* 7-8.1
Target support: Android 4.3 & up devices on ARM* and Intel®
Architecture, Microsoft Windows* 7-8.1 devices on Intel® Architecture
Environment set-up & maintenance
Analyze & Debug ShipCompileCreate
Frame Debugger System Analyzer Platform Analyzer Frame Analyzer Compute Code
Builder
Android Versions 4.3 & up, Intel® Architecture & ARM* devices.
Microsoft Windows* 7-8.1 Intel® Architecture devices
GNU C++ Compiler
Intel® C++ Compiler
Compute Code Builder
Media Threading Compute Code
Builder
Download: intel.com/software/inde
30
For on-device app testing: Intel® GPA System AnalyzerReal-time Remote Performance and Power Profiling
Intel® GPA System Analyzer running on a PC
Android Device
USB adb ConnectionWi-Fi adb Connection
Data
Real-time charts:• CPU metrics
• Graphics API level metrics
• Processor graphics hardware metrics
• Power metrics
Download Intel® GPA for FREE at intel.com/software/GPA
31
Debugging OpenGL ES code with Frame Debugger
Download Intel® GPA for FREE at intel.com/software/GPA
32
Intel® System Studio 2015 Overview
32
DEBUGGERS & TRACING ANALYZERS COMPILER & LIBRARIES
JTAG Interface System & Application code running on Linux* 1, Android* or Windows*
System Application Power & Performance
CPU / Graphics
Memory &
ThreadingC/C++
Compiler
Image, Signal, Media, Data & Math
Processing
Deep system-wide insight into power, performance, and reliability that helps accelerate time to market of Intel Architecture-based mobile and embedded systems and embedded applications
1 Linux*, Embedded Linux, Wind River* Linux*, Yocto Project*, Tizen*Embedded or Mobile System
Learn more at: http://intel.ly/system-studio
1 Linux*, Embedded Linux, Wind River* Linux*, Yocto Project*, Tizen*
33
Intel® VTune™ Amplifier XE 2015 for SystemsCPU Performance and Power Analysis
• Identify Hotspots and inefficient code• Cache Misses, Branch Mispredictions
• Drill down from Java & C/C++ to assembler code
35
Summary
• Apps submission started only on November 3rd(good opportunity to bring more visibility to your apps and games)
• Adding Android TV support isn’t necessarily much work
• No need for maintaining a separate APK
• Better x86 apps compatibility is nice to have for your apps/libs/engines
• Intel provides powerful tool suites for Android development