BogDan Vatra and Andy Gryc Qt on Android: Is it right for you?
Coffee and Code sessions Free, three-hour, hands-on session that delves into the internals of Qt on Android. Learn how to: set up the Qt development environment for Android apps use Qt Creator for Android deploy systems and sign packages use JNI to access and use Android Java APIs and much more NEW YORK June 10 SAN JOSE June 12 CHICAGO June 17 www.kdab.com/qt-on-android-sessions-usa
Why Android? Quicker time to market with professional product 1,2 Powerful (and familiar) GUI that s customizable 1,4 Wide range of supported hardware & software 1,2,4 Apps: access to existing and ability to develop new 1,4 Free (with caveats), generally non GPL 2 Low-power friendly 2 Brand recognition (one billion users) 3 1 Alan Levy, Plextek, http://www.plextek.com/images/docs/android.pdf. 2 Benjamin Zores, Linux Foundation, https://.../growth-of-android-in-embedded-systems.pdf 3 Gartner, http://www.gartner.com/newsroom/id/2645115 4 Hughes Systique, http://blog.hsc.com/android-vs-linux/
Why Qt? Full C++ library with support for networking, multimedia, SQL, Bluetooth, internationalization, etc Cross-platform framework supporting Windows, Linux, OSX, Windows CE, Windows RT, Embedded Linux, QNX, vxworks, Tizen, ios, BlackBerry, and Android Hardware accelerated graphics and Javascript for widget scripting (new in Qt 5.0) Clean and easy API with excellent documentation Full featured IDE, debugger, GUI designer Commercial and LGPL licenses available
Why Qt on Android? Portability of Qt apps to Android platforms Flexible deployment strategy (mobile, desktop, embedded targets) Speed of C++ in Android environment?
Example applications Medical Home Media Enterprise Automotive Gaming In-flight entertainment Heavy machinery White goods Universal remotes Network consoles Radio receivers
Qt basics Widget toolkit and convenience classes for building cross-platform C++ apps Widgets that mimic look & feel of native controls C++ plus Meta Object Compiler (moc) for adding event management, introspection Communication of events with objects in GUI or other async uses through signals and slots QtQuick: QML (JSON-like syntax) with JavaScript for rapidly building UIs QtCreator: Qt IDE and design tool
Qt on Android terminology Necessitas = Qt on Android for Qt4, hosted by KDE Qt on Android = Qt on Android for Qt5, hosted by Qt Project Qt Platform Abstraction (QPA) formerly Lighthouse project Allows creation of Qt ports by subclassing platform classes Ministro = Android app providing Qt helper services Resolves Qt library dependencies, loads libs as needed Significantly shrinks apk; Qt libs aren t bundled per app (up to 40MB/app)
Android device Qt app 1 Ministro Qt app 2 Qt app 3 Qt app 4 Qt libs Qt libs Qt libs Architecture Qt apps with and without Ministro
How does it work? All Android apps must have a Java component Including native apps: even Android NDK and Qt Java code loads your.so and uses JNI to call into it
How does it work? All Android apps must have a Java component Including native apps: even Android NDK and Qt Java code loads your.so and uses JNI to call into it Qt on Android needs some Java Java launcher loads your application and dependencies Java plug-in acts as bridge between QPA and Android
Application packaging MyQtOnAndroidApp.apk AndroidManifest.xml libmyapp(.so) QtApplication.java QtActivity.java resources & assets Ministro.aidl OR Qt libs (.so) Qt libs (.so) Qt libs (.so) QPA.jar
What about NativeActivity? Not in existence when Necessitas was started Access to Google APIs is only through Java NativeActivity primarily designed for games where GUI controls, dialogs, menus, etc are not needed Lacking features: Soft keyboard Surface management Menus Dialogs Multimedia
Application startup Android OS gets the default Activity (QtActivity) from manifest and runs it QtActivity loads Qt libs and your application QtActivity calls the startqtapplication() function (defined in QPA Plugin) startqtapplication() searches for main() function in application symbol table startqtapplication() creates a thread that calls your main() function, then it returns
Java Android Java C++ Your Qt App Qt libs Qt QPA Java/Qt communication C++ and Java have independent threads
Threading model C++ thread Runs your application and Qt framework Handles calls from Qt down into QPA for system services Java thread Handles Android calls and Android event loop JNI calls Handle synchronization between Qt and Android framework [If you add your own JNI calls, remember the Qt loop and Android loop are running in different threads!]
Qt Creator Support for Android built-in to Qt Creator - manage, build, deploy, debug, sign - manage AVDs - edit manifest (Android Manifest Editor) Many Androidcompatible examples Pre-installation of Android development environment required
Current status Module Qt 5.2 Qt 5.3 Qt Core Qt Multimedia Qt Quick Controls Qt SQL Qt Webkit & Qt WebkitWidgets Qt Widgets Qt Network, GUI, QML, Quick, Quick Layout, Test Available (missing system semaphores and shared memory) Available (missing QWidget based controls) Available (no Android style) Available (SQLite only) Missing Small problems with some dialogs (QFontDialog, QFileDialog, etc) Available Qt Android extras Additional functionality for development on Android Added API for starting intents and getting results Qt Bluetooth Missing Available Qt Positioning Missing Available Qt OpenGL Qt Concurrent, Declarative, Graphical Effects, ImageFormats, Script, ScriptTools, SVG, XML, XMLPatterns Limited to 1 top-level widget (can t mix QGLWidget with other QWidgets) Available Ability to mix any QGLWidget with any QtWidget (QGLWidget cannot overlap)
Future roadmap Module Release Android Native WebView Qt 5.4 Android style Qt Quick Controls Qt 5.4 Qt Creator Android CMake support Qt 5.4 Qt Core, shared memory Qt 5.5 Qt Services Framework Qt 5.5
Coffee and Code sessions Free, three-hour, hands-on session that delves into the internals of Qt on Android. Learn how to: set up the Qt development environment for Android apps use Qt Creator for Android deploy systems and sign packages use JNI to access and use Android Java APIs and much more NEW YORK June 10 SAN JOSE June 12 CHICAGO June 17 www.kdab.com/qt-on-android-sessions-usa
Additional resources Qt-on-Android blog: https://www.kdab.com/category/blogs/android/ Qt-on-Android development: http://qt-project.org/wiki/qt5forandroid Ministro project: http://necessitas.kde.org/necessitas/ministro.php
BogDan Vatra Andy Gryc bogdan.vatra@kdab.com andy@cx3marketing.com Thank you