Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mono for Android.net for Android HowTo: MultiTargeting-Portability- Interoperability for.netters 2011.06.30

Similar presentations


Presentation on theme: "Mono for Android.net for Android HowTo: MultiTargeting-Portability- Interoperability for.netters 2011.06.30"— Presentation transcript:

1 Mono for Android.net for Android HowTo: MultiTargeting-Portability- Interoperability for.netters 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net1

2 Motivation 1 – Financial Cross platform / Multitargeting / Portability – “write once, run everywhere” – Goal / Drive Time = Money greater or equal profit – Bigger market => more customers Necessity or perversion/masochism?? – Multitargeting Tools 2011-06-30 Java Native + UI – C++: Qt, AirPlaySDK (Marmalade), MoSync Html5 + css3 + JS (hype, even Windows 8,.net is dead?) – PhoneGap, Titanium, SenchaTouch.net ?? – Mono 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net2

3 Motivation 2 - Market Share Current Wikipedia SourceYearSymbianAndroidRIMiOSMicrosoftOther Gartner [24]2011 Q127.4%36.0%12.9%16.8%3.6%3.3% Gartner [25]201037.6%22.7%16.0%15.7%4.2%3.8% Gartner [25][26]200946.9%3.9%19.9%14.4%8.7%6.1% Gartner [26][27]200852.4%0.5%16.6%8.2%11.8%10.5% Gartner [27]200763.5%N/A9.6%2.7%12.0%12.1% References – http://en.wikipedia.org/wiki/Mobile_operating_system#Market_projection http://en.wikipedia.org/wiki/Mobile_operating_system#Market_projection 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net3

4 Motivation 3 - Market Share Projection Gartner OS2010[%]2011[%]2012[%]2015[%] Symbian111,57737.689,93019.232,6665.26610.1 Android67,22522.7179,87338.5310,08849.2539,31848.8 RIM47,4521662,60013.479,33512.6122,86411.1 iOS46,59815.790,56019.4118,84818.9189,92417.2 Microsoft12,3784.226,3465.668,15610.8215,99819.5 Other OS11,417.403.818,392.303.921,383.703.436,133.903.3 Total [k]296,647467,701630,4761,104,898 References – http://www.gartner.com/it/page.jsp?id=1622614 http://www.gartner.com/it/page.jsp?id=1622614 – http://socialtimes.com/gartner-idc-agree-about-mobile-marketshare-in-2015-but- disagree-about-2011_b56708 http://socialtimes.com/gartner-idc-agree-about-mobile-marketshare-in-2015-but- disagree-about-2011_b56708 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net4

5 Motivation 4 - Software Eng Multilayer architecture – Business Logic / Model x% – Presentation Layer / View y% 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net5 BL1 PL1 BLn PLn PL1 BL PLn

6 Motivation 5 - Software Eng Platforms – P = {WF, WPF, SL, ASP.net, WP7, MDrd, MTch} – E = sum(E(Bli)) + sum (E(PLi) =~ |P| * E(Bli) + sum (E(PLi)) Multitargeting – Less experts (architects, developers, testers…) – Less code -> less bugs – Less effort E = 1 * E(BLi) + sum (E(PLi)) – Developing factor 1/ |P| - add testing => ask any PM or C[EF]O 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net6 BL1 PL1 BLn PLn PL1 BL PLn

7 Software Eng - MultiTargeting Strategies – Obey standards c/c++ digression: c++ was killed by standardization (IMHO) – Stick with proprietary tech (one or all??) Java MS.net – Multi?? Yes -> mono targets unixoids (Linux, Solaris, etc) » Mono http://www.go-mono.comhttp://www.go-mono.com » Politics… http://www.xamarin.comhttp://www.xamarin.com 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net7

8 Motivation 5 - Religion CASE conference few weeks ago – Context: “.net on Android (linux) is nonsense” regarding presentation about Monodroid on MobileMonday in Zg 2011-02-07 – Comments: … just somebody’s opinion Haters will always hate - paranoia Freedom (to choose platform and market share) – ms(2012, {A,iOS,WP7})=78.9% ms(2015, {A,iOS,WP7})=85.5% – just say no! ;) 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net8

9 Android 1 - Intro Android – Is linux with modified 2.6 kernel – Set of native libs – Application framework written in java Dalvik VM – Architecture ARM6+ x86 v.2.2 Froyo Rich development environment – Eclipse and … 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net9

10 Android 1 - Intro class Android : Linux, IApplicationFramework { Kernel k = new Kernel (Customized.Yes); ApplicationFramework appfx; VirtualMachine vm; Libraries s[] = new Libraries[]{ new NativeGraphicsOpenGL_ES(1.0), // … more } public Android() { if (Arch < ARM6) throw new NotImplementedException(); If (Arch == x86) Version = new Version(“2.2”, “Froyo”); } } Rich development environment – Eclipse and … 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net10

11 Android 2 – Architecture/Stack 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net11

12 Android 3 – App Fx 1 Components : Activity – application component that provides a interaction screen (or not) Intent – messaging facility for late run-time binding between components in the same or different applications Service – application component that can perform long-running operations in the background and does not provide a user interface. ContentProviders – providers store and retrieve data and make it accessible to all applications BroadcastReceiver – broadcast receiver is a component that responds to system-wide broadcast announcements 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net12

13 Android 4 – App Fx 2 Activities Orchestrates a UI view Applications are composed of 1-to-Many activities One activity marked as main and shown first upon launch 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net13

14 Android 5 – App Fx 3 Intents Eventing mechanism Intent objects are passive data that is of interest to the component that is receiving the intent Filterable 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net14

15 Android 6 – App Fx 4 Services Services: – Long lasting background work – No UI Like Windows services Android service are what you’d expect. Possible to bind to an ongoing service and communicate via exposed interface Runs in main application process but doesn’t block other components or UI 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net15

16 Android 7 – App Fx 5 ContentProviders Queryable application data stores Unification: Only way to share data between apps – ships with common providers – New Provider => app data becomes public – Add your data to existing provider Types: Contacts, Mails, SMS, audio, video, images, Documents 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net16

17 Android 7 – App Fx 5 ContentProviders 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net17 ApplicationsContent Providers Contact s MusicVideosPictures…

18 Android 8 – App Fx 6 BroadcastReceivers BroadcastReceivers: 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net18

19 Android 9 – App Fx 7 External data External elements/data : Resources - more often (java: ProjectRootDir/res/) – Compiled/generated by aresgen into R.java – strongly typed – Accessed through R.Drawable.Id Assets (java: ProjectRootDir/assets/) – For raw access (no ability to extract raw data from Resource) 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net19 FunctionPathAccess programatically UIlayout/filename.xml layout-land/main.axml // R.layout.filename TextView tv = findViewById(Resource.id.nameTextbox); Bitmapsdrawable/icon.pngDrawable d = res.getDrawable(Resource.Drawable.icon);getDrawable Textvalues/strings.xmlString s = getString(Resource.String.hello);getString

20 Android 10 - Resources/Assets Abstraction layer which helps decouples code Resources – Images, layout descriptions, binary blobs and string dictionaries – Localization – Multiple displays – Different hardware configurations Assets + AssetManager – Makes managing assets easier 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net20

21 Android 10 – App Fx 8 UI Layouts – Defined in xml (*.axml in VS) like XAML, XHTML – During build generated as objects Activity contains View[s] and/or ViewGroup[s] have appearance – Android.View.View{} – widgets Button, CheckBox, TextView, EditText, AutoComplete, ListView, ImageView, Gallery, pickers – Android.View.ViewGroup{} - specialization, order, orientation LinearLayout, AbsoluteLayout, RelativeLayout, tableLayout, FrameLayout, ScrollView 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net21

22 Android 11 – App Fx 9 UI Each activity is given a default window to draw in. Content of the window is provided by a hierarchy of views A view hierarchy is placed within an activity's window by the Activity.SetContentView() Activity/View – onCreate – onStart – onResume – onPause – onStop – onDestroy 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net22

23 Android.Activity.Lifecycle 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net23

24 Android 11 – Dalvik VM Register-based (normal Java VMs are stack based) – Requires a.class to.dex transformation Runs multiple VMs efficiently JIT (as of Android 2.2) Each Android Application: – Runs in their own process – Runs on their own VM One of main sources of dispute Oracle vs. Google – Java ME – license does not allow changing VM 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net24

25 Android 12 - Tools Development – JDK + Android SDK – IDE - eclipse – UI - DroidDraw SDK – SDK + AVD Manager – Android Debug Bridge – adb.exe (cmdline) Interface to Emulator/Device – Emulator.exe – Build process Javac (for class files) + dex (.dex files for Dalvik VM) apkbuilder – generates apk (zip file) jarsigner (signing) + zipalign (optimizations) 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net25

26 Android 12 – Debugging Adb + Logging – adb logcat – android.util.Log Debugging on device – Android SDK + USB drivers – Wi-fi, though deployment over USB – Update drivers for unrecognized device in Device Manager with non-google USB drivers (android.bat in SDK dir) – Selecting image or device! – Error connecting stderr/stdout check ports IP address, firewall, VS – tools – options 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net26

27 Android 13 - Deployment Deploy to – Android Virtual Device – Device: phone || pad Debug capabilities on both Sell (eventually) – Android Marketplace – Amazon App Store 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net27

28 Android 14 – Refs / Links Links – http://developer.android.com/index.html http://developer.android.com/index.html – http://www.androiddevelopment.org/ http://www.androiddevelopment.org/ – http://www.vogella.de/articles/Android/article.html http://www.vogella.de/articles/Android/article.html Opinion (personal) : – Pros Openness – Speed of development – Cons Openes – Fragmentation/Diversity (versions …) – Security 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net28

29 Mono for Android 1 - Intro Ex – monodroid – Commercial Product from Novell (was) ~$99 student / $399 individual / ~$999 enterprise MonoForAndroid V 1.0.1 – Is Extension to Android which wraps Android as app framework – Contains: MonoVM vm Managed Mono Libs: RSilverlight, Rdesktop Android and Mono Callable Wrappers 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net29

30 Mono for Android 2 (monodroid) Ex – monodroid – Commercial Product from Novell (was) ~$99 student / $399 individual / ~$999 enterprise MonoForAndroid : Android { MonoVM vm; ManagedMonoLib[] libs = new ManagedMonoLibs[] {RSilverlight, RDesktop}; AndroidCallableWrappers[] acws; } V 1.0.1 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net30

31 Mono for Android 3 - Intro Android Specific: – Compiler – Mono VM – Libraries -SDK -Namespaces -System.* -Mono.* -Android.* -java.* -Extended subset (oxym??) of several SL and desktop assemblies 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net31

32 Mono for Android 4 – Architecture/Stack 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net32

33 Mono for Android 3 - Design Principles Follow the Framework Design Guidelines Allow developers to subclass any Java class – Derive from class, call base ctor for chain, c# overriding – Common Java tasks easy, hard ones possible – JavaBean properties as c# properties Strongly typed API type safety, minimize errors, intellisense, docs, C# constructs (delegates, lambdas, anonymous methods) instead of sinlge method interfaces – c# delegates for widget events (less cumbersome than java hooking) Mechanism to call Java libs Bindings - Java.util.collections -> System.Collections.Generic – Use Helper classes Android.Runtime.JavaList et al to reduce marshalling overhead between Mono VM and Dalvik VM Threading (runnables) Android.Activity.RunOnUIThread() Resources (Resources/drawable-hdpi/* -> Resource object Android constants -> c# enums Android.Runtime.JNIEnv managed wrapper for Java Native Interface JNI calls 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net33

34 Mono for Android 4 - Tools + Build Android SDK IDE – Visual Studio 2010 Profesional + – MonoDevelop Monodroid tools – VS plug in – Aresgen: resource generator (resgen) – mandroid.exe – monodroid.exe Generates ACWs. AndroidManifest.xml and packages app – Shared runtime for debugging on emulator 18MB + – Signing needed for devices, slow not part of build – AndroidManifest.xml controlled through c# Attributes 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net34

35 Mono for Android 5 - Development IDE – VS 2010 Professional+ (Windows) Almost no need to leave VS External tools Project and Item templates – MonoDevelop 2.6 (Windows, Linux, Mac OS X) Principles – BL – classical (desktop).net, c# – PL – different, but resembles XAML (WPF, SL, SLWP7) – Debugging - Like “normal” debugging in VS – Logging (no Console) (android.util.Log) Android.Util.Log.Info(“some_tag_for_app”, “message”); Android.Util.Log.Warn(“some_tag_for_app”, “message”); Android.Util.Log.Error(“some_tag_for_app”, “message”); 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net35

36 Mono for Android 6 – Tips&Tricks Principles – Achitecture layers BL /Model – develop as classical (desktop) – tested in desktop Mono - Mono PL – Do learn Android SDK Tools (need another session) – VS Project Linker – VS Productivity power tools – VSCommands – VS Power Commands 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net36

37 Mono for Android 7 - Diffs Android – org.xml.sax.XmlReader – org.xml.sax.helpers.Handler Mono 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net37

38 Mono for Android 8 – Diffs 2 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net38 () => { Console.WriteLine(“Lambdas”); }; Java C#

39 Mono for Android 9 – Pros 1 Mono supports lots from netfx 3, 3.5 and 4 – Attributes: no need to edit AndroidManifest.xml – Lambda expressions – anonymous delegates – LINQ – WCF (alpha) 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net39

40 Mono for Android 7 – Pros 2 Platform Multitargeting (application suites) – Targets: Desktop: WF, WPF Web: ASP.net, SIlverlight Mobile: WP7, Android, iOS – BL =M in MVC or MVVM % ??? ( assume 30% with databinding 50%+) BL code reuse -> single unit tests, less bugs Mono supports lots from netfx 3, 3.5 and 4 – lambdas, anonnymous things, LINQ, WCF (alpha) 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net40

41 Mono for Android 8 - Pros 3 Mono for Android story not as compelling as MonoTouch. GC, decent IDE, not Objective-C Opportunities for re-use across platforms iOS, Android, Windows Phone 7 non-UI components MonoGame which is a port of XNA Development tooling and environment Visual Studio MonoDevelop C# > Java Friction still due to Java idioms and architecture. 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net41

42 Mono for Android 9 – Cons 1 Performance – 2 VMs: Mono + Java VM – Dalvik - interop/marshaling very controversal test results depending on context – (UI yes, rest can be avoided) – No shared runtime Release takes time (linker analyzes dependencies) – http://www.koushikdutta.com/2009/01/dalvik-vs-mono.html http://www.koushikdutta.com/2009/01/dalvik-vs-mono.html Debugging: Slow (some have abandoned because of this) Limitations – Java proxy classes generation (automatic) => cannot generate all code! – ACW generated based on static analysis of assemblies => no dynamic languages Not native – wraps native Android java libs (java is not native either) 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net42

43 Mono for Android 10 – Cons 2 Difficulty / Ignorance / Laziness – dev must learn new platform Android API only PL - UI layer – c# and java althoug quite similar Friction still due to Java idioms and architecture Political – Microsoft is in/out (haters hate it anyway) – Mono status dead??? – no it is open source Progress dynamics - vary 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net43

44 RIP Mono 2002-2011 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net44

45 Mono for Android 12 – Refs / Links1 Official – http://mono-android.net gone from Novell web in 2011/06/ ???????? http://mono-android.net – Download (free cannot deploy to device, only emulator) http://mono-android.net/Welcome – Future Xamarin http://www.xamarin.comhttp://www.xamarin.com Diverse http://morewally.com/cs/Default.aspx http://blogs.infosupport.com/blogs/willemm/archive/2011/03/23/intr oducing-monodroid.aspx http://blogs.infosupport.com/blogs/willemm/archive/2011/03/23/intr oducing-monodroid.aspx http://www.mono-droid.com/ http://conceptdev.blogspot.com/ 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net45

46 Mono for Android 13 – Refs / Links2 Code samples https://github.com/mono/monodroid-samples https://github.com/kevinmcmahon/MonoDroid101 https://github.com/gshackles/Sample- Projects/tree/master/MonoDroid/MonoDroidSamples https://github.com/gshackles/Sample- Projects/tree/master/MonoDroid/MonoDroidSamples https://github.com/gshackles/Sample-Projects/ https://github.com/conceptdev/RestaurantGuide/tree/master/RestGuide_And roid https://github.com/conceptdev/RestaurantGuide/tree/master/RestGuide_And roid Comparison http://www.holisticware.net/HolisticWare/Know-How/Development/ui- development-presentation-layer-framework-comparison.aspx http://www.holisticware.net/HolisticWare/Know-How/Development/ui- development-presentation-layer-framework-comparison.aspx Applications http://mix11.confapp.com/ http://www.barnesandnoble.com/w/spawn-eodsoft/1030870830 MonoTouch showcase: – http://monotouch.net/Apps/?tag=/Showcase http://monotouch.net/Apps/?tag=/Showcase – http://www.eodsoft.com/artisan.html http://www.eodsoft.com/artisan.html 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net46

47 Mono for Android 14 – Q&A ?????????????????????????? VB – Mono – yes – Mono 4 Android – no no Vb templates Compiler status? 2011.06.30 MSCommunity.DevUG.Zgmcvjetko@holisticware.net47


Download ppt "Mono for Android.net for Android HowTo: MultiTargeting-Portability- Interoperability for.netters 2011.06.30"

Similar presentations


Ads by Google