You can ask ThinkPower (Xamarin partner in Taiwan) ◦ how Xamarin.Android works ✕ how Xamarin IDEs work (except for UI designer) What to discuss here (and what not) http://goo.gl/ZvNBxN
Write C# code to use native platform API C# code sharing across platforms (iOS, Android, Windows Phone) brings .NET oriented technology like MVVM architecture Use Xamarin Studio or Visual Studio as IDE. http://goo.gl/ZvNBxN
- Browser RIA platform CoreCLR: subset of .NET Framework for small footprint Windows Phone Silverlight based API, extended for mobile (sensors, contacts etc.) .NET Framework Windows Phone Silverlight
IDE on top of GTK# Linux desktop apps Mono also embraces .NET ecosystem ASP.NET, NuGet, OSSes ... .NET Foundation COSCUP 2014: Hacking Mono and .NET http://goo.gl/ZvNBxN
Android") platform API in C# / .NET (as well as .NET System.* API) Xamarin Studio (MonoDevelop + Xamarin addin) or Visual Studio addin http://goo.gl/ZvNBxN
in C++ toolchains - gcc / clang bionic libc Not all of Android API are supported NativeActivity - C++ Android API to build apps All Android apps conform to Android framework. ... which is Java based. Native apps too. http://goo.gl/ZvNBxN
a completely native activity" "It is possible to write a completely native application" It still runs on Dalvik/ART VM. "You should still create your project with Eclipse or <snip>" WTF, native app works like Java app... http://goo.gl/ZvNBxN
while JVM also runs no "transpiler" to dex CIL natively runs on mono 2) Use Java API [xamarin:architecuture] Mono.Android.dll - .NET friendly version of android.jar API (no NativeActivity / native API)
API" mono runtime built with NDK and run on Android OS entirely written in C depends only on libc Android: Linux kernel + bionic libc http://goo.gl/ZvNBxN
every Java object is based on this class. Binding is not only for android.jar; any Java library can be bound. Though bindings have limitation. (e.g. on generics) http://goo.gl/ZvNBxN
or Visual Studio (addin) on Windows (requires Business+ license) xbuild (mono MSBuild) or MSBuild is usable only with Business+ license... creating app is doable only if you can manually create .csproj... http://goo.gl/ZvNBxN
that invokes Java methods throuh JNI funcs Need two way operations: MCW (Mono Callable Wrappers) - .NET code to invoke Java ACW (Android Callable Wrappers) - Java code to invoke .NET also called as JCW (Java Callable Wrapper) (1) Java-Mono Interop http://goo.gl/ZvNBxN
callbacks by Android framework e.g. user resumes app -> Activity.onResume() -> our Activity.OnResume() generates Java source for each Java-based object http://goo.gl/ZvNBxN
framework) Zygote: Java app process manager App process is fork()-ed from Zygote. Application instance is created (referencing AndroidManifest.xml). ActivityManagerService handles app lifecycle. 6.深入了解ActivityManagerService
<provider a:name="mono.MonoRuntimeProvider" ...> <receiver a:name="mono.android.Seppuku" ...> XA has its own app class Activity element etc. is automatically generated content provider that initializes mono app killer signal (for debugger)
the app, with content provider list from manifest. ActivityThread.handleBindApplication() creates custom Instrumetation if required Then Instrumentation.callApplicationOnCreate(app) Application.onCreate() initializes app's content providers. and thus initializes Mono
framework) Android Java framework launches app starts Application, initializes Provider, launch Activity. All described in auto-generated AndroidManifest.xml. mono.RuntimeProvider initializes monodroid runtime. (rephrase this too: Java classes are generated, and we use them)
JVM and mono VM. What if JVM destroys an object that mono references? What if Mono destroys an object that Java references? ... no, we don't want either. Too advanced to discuss here, see: http://goo.gl/FgirvY http://goo.gl/ZvNBxN
Xamarin app too. mobile apps - better as small as possible Packaging is heavyweight process esp. for Xamarin Debug build: faster is better Release build: smaller is better
apps need Resource IDs in C# int too res/layout/* -(aapt)-> R.java -(msbuild)-> Resource.designer.cs Res IDs should be const (switch-case requires consts) except for library project (static readonly int in Java too) Res IDs are regenerated by IDEs whenever layout XML is saved
skip it as long as we can. fast deployment - build and install apk only when required *.dll are not part of *.apk IDE/SDK needs to copy them to app storage before running app app requests "Shared Runtime" or "Platform" apk to give dlls at run time. embedded deployment - normal packaging, everything into *.apk *.dll are assets
managed code like proguard shrinking code (upcoming) proguard support - can remove unused Java code complicated for XA; some config files auto-generated Heavyweight task - we don't want to run it every time → usually run only in Release build
/ Release - small apk is better Debug: APK build is slow, so... we build apk for debugging only once: fast deployment "Debug Runtime apk" and "Platform apk" offer framework code (dlls) Release: Mono runtime and assemblies are big, so... we have "Linker" to shrink assemblies (too advanced to discuss details) Packaging and Deployment, briefly http://goo.gl/ZvNBxN
don't know there were better emus and complained about them(!) accelerated x86 emulator based on VirtualBox Everyone knew it's doable, configuring it was not easy. we can still use Google emulators (x86/HAXM too) http://goo.gl/ZvNBxN
Designer implemented on Xwt (x-plat UI toolkit for Gtk#/Mac/WPF) AOSP layoutlib UI view drawing reimplemented using Java2D used by Eclipse ADT and Android Studio too, as well as Xamarin http://www.slideshare.net/peterbuck/developing-for-android http://goo.gl/ZvNBxN