Department of Computer Science Institute for System Architecture, Chair for Computer Networks
Application Development for Mobile
and Ubiquitous Computing
10. Cross-Platform Development
Dr. Ing. Thomas Springer
Technische Universität Dresden
Chair of Computer Networks
Lecture Structure
Adaptation and Context-awareness Mobile Internet Mobile Middleware Application Development Disconnected Operations Mobile Databases Location-based Services Communication Mechanisms Android iOS .Net Compact Framework/ Windows Phone 7 Java ME OSGi Cross-Platform Development
Strong fragmentation of
market for mobile device
platforms
Market changes quickly
High update rate
• Device features
• Platform APIs
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 3
Why Cross-Platform Development?
Mobile Device
CLDC Configuration, KVM Midlet Suite Midlet Suite ...
MIDP Profile Optional Packets Mobile Device Dalvik VM + Core libraries Libraries App .apk App .apk ... Application Framework Mobile Device App .ipa App .ipa ... Media Custom Frameworks UIKit Foundation Core Services Cocoa Touch Mobile Device App .xap App .xap ... App Model Silverlight Kernel UI Model Cloud Integration XNA HTML/JavaScript Common Language Runtime
Frameworks
Java ME
Project
Android
Project
iOS
Project
Windows Phone
Project
High development effort
• Know-how for multiple platforms
• High update rates of technology
• Customers don‘t pay per platform but for project
Short time to market
• Fast support of platform changes/new platforms
High maintenance effort
• Manage multiple code bases
• Avoid inconsistencies
Mobility Support
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 5
Write once, run everywhere?
Mobile Device
CLDC Configuration, KVM Midlet Suite Midlet Suite ...
MIDP Profile Optional Packets Mobile Device Dalvik VM + Core libraries Libraries App .apk App .apk ... Application Framework Mobile Device App .ipa App .ipa ... Media Custom Frameworks UIKit Foundation Core Services Cocoa Touch Mobile Device App .xap App .xap ... App Model Silverlight Kernel UI Model Cloud Integration XNA HTML/JavaScript Common Language Runtime
Frameworks
Cross-Platform
How can we achieve it?
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 7
Mobile Device
Hardware Operating System
CLDC Configuration, KVM Midlet Suite Midlet Suite ...
MIDP Profile Optional Packets Mobile Device Dalvik VM + Core libraries Hardware Libraries App .apk App .apk ... Application Framework Linux Kernel Mobile Device Hardware App .ipa App .ipa ... Media Mach/BSD Kernel Custom Frameworks UIKit Foundation Core Services Cocoa Touch Mobile Device Hardware App .xap App .xap ... App Model Hardware Foundation Silverlight Kernel UI Model Cloud Integration XNA HTML/JavaScript Common Language Runtime
Frameworks
Cross-Platform
Heterogeneous Hardware
• Form factors
• Resources
• Device features (touch input, buttons, connectivity, sensors, …)
Heterogeneous Software Platforms
• Execution environment
• Programming languages
• Platform APIs, UI Kit
• App anatomy and programming model
• Tool chains
• Deployment and verification process
User expectations
• Look and Feel
• Design guidelines
A
device platform
is a combination of device hardware,
operating system, runtime system, libraries, and
frameworks forming a standard execution environment for
applications on devices which run that platform.
A device platform has a characteristic set of features:
• Specific „look and feel“ (UI guidelines and interaction concepts)
• App runtime defining app anatomy and lifecycle
• Developer tool chain (programming languages, libraries, APIs)
• Specific app distribution and deployment process
Native Code
is code which can be directly executed within
the standard execution environment of the device platform.
It has full access to the platforms libraries and frameworks,
possibly also to operating system APIs and hardware
features.
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 9
Terms and Definitions
Device Platform
An App is a specific type of applications created for
and running on a particular device platform.
A Native App is an App which is created for and can
be deployed and started on a device platform whithout
any further dependencies.
A
Mobile App
is typically created for and running on a
mobile device platform. It‘s started from the home
screen, supports graphically-oriented interactions and
occupies the full screen.
Terms and Definitions
App
Mobile App Types
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 11
Device Platform
Interpreter
Cross-Platform App
(+ Native Ext.)
Cross-Platform API
Native
Code
Interpreted
App
Web
browser
Web App
Hybride App
What to start with?
Cross-Platform Development
Approaches
Execution Phase
Build Phase
Implementation
Phase
Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic
Model-driven Development
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 13
Cross-Platform Development
Approaches
Execution Phase
Build Phase
Implementation
Phase
Model-to-Model-Transformation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation Interpretation
Cross-compilation to native code
Cross-Platform Development
Approaches
Execution Phase
Build Phase
Implementation
Phase
Machine Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Execution Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation Interpretation
Support for abstract runtime
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 15
Cross-Platform Development
Approaches
Execution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation Interpretation
Script languages
Cross-Platform Development
Approaches
Execution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation Interpretation
Translate to other programming languages
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 17
Cross-Platform Development
Approaches
Execution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Source-to-Source-Translation (Code Transformation) Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation InterpretationCross-Platform Development
Approaches
Execution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Source-to-Source-Translation (Code Transformation) Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation InterpretationTranslation Approach
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 19
Translation Approach
Execution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Source-to-Source-Translation (Code Transformation) Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation InterpretationInterpretation Approach
Translation ApproachExecution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Source-to-Source-Translation (Code Transformation) Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation InterpretationWeb-based Approach
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 21
Interpretation Approach Translation Approach
Execution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Source-to-Source-Translation (Code Transformation) Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation Interpretation Web-based ApproachHybrid Approach
Translation ApproachExecution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Source-to-Source-Translation (Code Transformation) Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation Interpretation Hybrid ApproachModel-driven Approach
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 23
Interpretation Approach Translation Approach Model-driven Approach
Execution Phase
Build Phase
Implementation
Phase
Machine Code Byte Code Cross-Compilation / JIT-Compilation Model-to-Model-Transformation Source-to-Source-Translation (Code Transformation) Interpretation Interpretation AOT- / JIT-Compilation Execution Compilation Mobile Device Source Code Executable ProgramDesign Phase
Model GUI Logic GUI Logic Model-to-Code-Transformation Interpretation Web-based Approach Hybrid Approach
Step-wise desing
Models for UI and application logic
Integrated tool environment to consistently develop UI and
application logic
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 25
Example EMODE
Model-Driven Approach
Execution Phase Implementation/Build Phase JavaME Design Phase Refinement Abstract Design Task Model Concept Model Abstract UI Model Functional-Core-Adapter Model Context-Model Concrete UI Model Executable Task Model FCA-Code Context- Provider-Code Source Code Interpretation (EMODE-Runtime Environment) other Platforms...
M-M M-M M-M M-C M-C M-C M-C M-M = Modell-to-Modell-Transformation M-C = Modell-to-Code-Transformation
JavaME as common
code base
Parameterized code to
customize code for
different platforms
Source-to-Source
Transaltion to various
programming
languages
Transformed code can
be further edited
Compatibility libraties
per platform to bridge
API-gap
No DIE, but translation
scripts, compatibility
Bedrock
Translation Approach
Execution Phase Buildphase JavaME-Source Code Implementation Phase JavaME-Source Code Source-to-Source-Translation C++-Source Code Java-Source Code (Android) Dalvik-Bytecode Maschinen-code Maschinen-code C#-Source CodeActionScript ActionScript-Bytecode CIL-Code CIL-Code HTML5, JavaScript JavaME BlackBerry Android iOS, Bada, Symbian, WinMobile, webOS, BREW, ... Windows Phone Windows Desktop (.NET) Flash Player Browser JavaME-Bytecode BlackBerry-Bytecode ... ... Compilation Compilation Compilation Cross-Compilation Cross-Compilation Compilation Compilation Compilation Interpretation Interpretation Interpretation Interpretation Interpretation Interpretation Interpretation Execution Execution Code-Transformation, Compatibility Libraries
Approach using m:1:n language translation
XML as common language for byte code based on Java Bytecode
Transformation based on XML Stylesheets
Compatibility libraries used to port apps (even from Android to iOS)
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 27
XMLVM
Translation Approach
Abarbeitungsphase Buildphase Implemen- tierungs-phase Realisierung durch XMLVM (Xcode: Cross-Kompilierung zu Maschinencode; Ausführung) Interpretation Java-Bytecode Java-Plattform .NET-Plattform iOS Browser XMLVM-JVM (XML) JavaScript-Quellcode C/C++-Quellcode Interpretation Interpretation CIL-Bytecode BCEL DX XSL XSL MBEL Interpretation Cross-Kompilierung ... ... Objective-C-Quellcode Python- Quellcode XMLVM-CLR (XML) XMLVM-DEX (XML) Java-Bytecode Java-Quellcode Kompilierung Kompilierung CIL-Bytecode XMLVM-CLR, -DFA (XML) .NET-Quellcode (C#, VB, ...) Ruby(YARV)-Bytecode Ruby-Quellcode Kompilierung Ruby BCEL XSL MBELBCEL = Byte Code Engineering Library MBEL = Microsoft Bytecode Engineering Library
Qt C++ as source
Virtual GUI toolkit
Cross-platform libraries allow access to many device specific
features (camera, contacts, Maps, GPS, Sensors, etc.)
Qt Quick allows declarative description of touch-based Uis
• Interpreted in special runtime engine
Qt
Translation Approach
Abarbeitungsphase Buildphase Implementierungs- phase Qt C++-Quellcode C++-Quellcode...
Ausführung Präprozessor Maschinen-code Symbian, MeeGo, Maemo, Windows, Linux, Mac OS Maschinen-code...
Cross-Kompilierung Ausführung
Specific AIR runtime engine + libraries
GUI declaratively described in MXML (special extensions to
support touch-based interactions)
GUI description compiled to ActionScript code
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 29
Adobe Air
Interpretation Approach
Abarbeitungsphase Buildphase Implemen-tierungs- phase ActionScript-Quellcode ActionScript-Bytecode Kompilierung Maschinen-code...
Interpretation (separat zu installierende AIR-Laufzeitumgebung) Ausführung AOT-Kompilierung Interpretation (integrierte AIR-Laufzeitumgebung) Android, Windows, Linux, Mac OS iOS TV BlackBerry Tablet OS
Ruby, HTML, CSS and JavaScript as common code
base in one project
Application bundled with lightweight web server +
Rhodes Ruby Framework + Ruby VM
Rhodes Mobile
Interpretation Approach
Execution Phase Build Phase Implementation Phase Interpretation (bundled VM) Interpretation BlackBerry Compilation Compilation Ruby-Bytecode BlackBerry-Bytecode iOS Android WinMobile Interpretation (Browser-Engine of Platform, WebView) One Cross-platform Project Ruby-Source ode HTML-, CSS-, JavaScript-Source Code
Supports development of client and server side code for
Web-Applications in Java
Source-to-Source translation to HTML, JavaScript and CSS
(High-leve Translator
JavaScript Code optimized for various browsers
Mobile support with specific extensions of GWT libraries
(GWTMobile, GWT-Mobile-Webkit)
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 31
Google Web Toolkit (GWT)
Web-based Approach
Execution phase Buildphase Implementation phase Java-Source Code (Client) JavaScript-, HTML-, CSS-Source Code Interpretation Interpretation Browser (Client) Java-Plattform (Servlet Container / Google App Engine) Source-to-Source-Translation Java-Bytecode Compilation Java-Source Code (GWT Servlet)
Combination of
Web-based and Translation
approach
Web-technologies to
create UI + logic
Native Code to access
specific device
features like sensors,
camera, etc.
Cross-platform API for
each target platform
(PhoneGap JavaScript
API)
Native UI widgets are
Phone Gap
Hybrid Approach
HTML, CSS, JavaScript
iOS PhoneGap Bib (JavaScript)
iOS PhoneGap Bib (Nativ)
PhoneGap Cross-Platform-API for JavaScript
(Nativer Wrapper Code) iOS-Plattform-API Android PhoneGap Bib (JavaScript) Android PhoneGap Bib (Nativ) (Nativer Wrapper Code) Android-Plattform-API
App Projekt for iOS
App Projekt for Android
Comparision
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 33
Tool Supported Device Platforms Programming
Language Approach App Execution
Env.
Generic App
parts Native
GUI-Widgets
Supported Platform-Features Bedrock Android, Antix Game Player, bada, BlackBerry,
BREW, Flash, iOS (iPhone, iPad), JavaME, Nintendo DS / DSi / DSiWare, Sony PSP / PSP Minis,
Symbian, webOS, Windows Mobile, Windows Phone 7, Browser (HTML5)
Java (JavaME)
Source-to-Source-Translation to C++, Java, C#, ActionScript,
JavaScript;
Plattform-SDK for Cross-Compilation
native Logic, GUI no
Qt Symbian, Maemo, MeeGo, Windows, Linux, Mac OS C/C++ Cross-Compilation native Logic, GUI Yes
XMLVM iOS, Android, .NET-Plattform, Java-Plattform, weitere Zielsprachen: JavaScript, Python, C++, Objective-C
Java, Ruby, Sprachen der .NET-Plattform
Bytecode-Compilation native Logic Yes
Adobe AIR iOS (iPhone, iPad), Android, Blackberry Tablet OS,
Desktop-PCs, TV ActionScript, MXML Bytecode-Interpretation / AOT-Compilation (iOS) Engine / native Logic, GUI partly
Kony Android, iOS, J2ME, BlackBerry, Symbian, Windows
Mobile, Windows Phone 7, webOS, BREW; Tablets: iOS, Android, BlackBerry, webOS;
Lua Bytecode-Interpretation /
Source-to-Source-Translation, Cross-Compilation (iOS)
Engine /
native Logic, GUI yes
Rhodes Android, BlackBerry, iOS (iPhone, iPad), Windows
Mobile, Windows Phone 7 Ruby, HTML, CSS, JavaScript Interpretation of scripting languages
Bytecode-Interpretation
Engine,
hybrid Logic, GUI partly
Titanium Mobile
Android, iOS (iPhone, iPad), BlackBerry, Titanium
Mobile Web SDK: Browser JavaScript Interpretation approach Engine Logic, GUI yes
Sencha Touch
iOS (iPhone, iPad), Android, BlackBerry (incl.
PlayBook) JavaScript, (HTML, CSS) JavaScript-Application-Framework Web Logic, GUI No
Google Web Toolkit
Any device with Web browser Java
Source-to-Source-Translation to HTML, CSS, JavaScript
Web Logic, GUI No
PhoneGap iOS (iPhone, iPad), Android (Smartphones, Tablets), webOS, Symbian, BlackBerry, Windows Phone, bada
Native Code, HTML, CSS, JavaScript
Strong fragmentation of market for mobile device platforms
Cross-Platform frameworks try to bridge the gap
Large number of tools following manifold approaches
• Methodology
• Target platforms
• Native features
• App anatomy
• User interactions
No tool fulfills all requirements
In sum: instead of „Write once, run everywhere“ it‘s more
„
Write once, run many“
Possible strategy for projects
Dirk Hering: Analyse von Methoden und Werkzeugumgebungen zur
plattformunabhängigen Entwicklung mobiler Applikationen,
Diplomarbeit, TU Dresden, 2010
Kramer, Dean ; Clark, Tony ; Oussena, Samia: MobDSL: A Domain
Specific Language for multiple mobile platform deployment. In:
2010
IEEE International Conference on Networked Embedded Systems for
Enterprise Applications (NESEA)
, 2010, S. 1–7
Hamann, Thomas ; Hübsch, Gerald ; Springer, Thomas: A
Model-Driven Approach for Developing Adaptive Software Systems.
DAIS
2008, Proceedings
Bd. 053 (LNCS), pp. 196–209, 2008
Kassinen, Otso ; Harjula, Erkki ; Koskela, Timo ; Ylianttila, Mika:
Guidelines for the Implementation of Cross-platform Mobile
Middleware. In:
International Journal of Software Engineering and Its
Applications (IJSEIA)
4 (2010), Nr. 3, S. 43–57
Calvary, Gaëlle ; Coutaz, Joëlle ; Thevenin, David ; Limbourg,
Quentin ; Bouillon, Laurent ; Vanderdonckt, Jean: A Unifying
Reference Framework for multi-target user interfaces. In:
Interacting
with Computers
15 (2003), Nr. 3, S. 289–308
Dr. Thomas Springer Application Development - 10. Cross-Platform Development 35