Jonathan Pryor
Xamarin.Android Lead
Xamarin
jonp@xamarin.com
What’s New in
Xamarin.Android
What’s in Xamarin.Android
IDE
Runtime
Java library binding
Packaging
Unified Components
•
•
•
•
•
Visual Studio
Layout Editor
Non-Modal Deployment
Target Selection
•
•
•
Released
Xamarin Studio
Layout Editor
Razor HTML Generator
•
•
Released
Runtime: New Foundation
Mono 3.0 base, includes most .NET 4.5 APIs
Stream.ReadAsync(), System.Net.Http.dll
“Breaking” Change on OS X:
new Java.Lang.Object() // CS1540
Xamarin.Android ≤ 4.6: “Silverlight” based
Xamarin.Android ≥ 4.7: .NET 4.5-based -
System.Configuration
•
•
•
•
•
Beta
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Runtime: C#4 Dynamic
var books = @"<books pubdate='2009-05-20'>
<book price='45.99' title='Open Heart Surgery for Dummies'>
<authors>
<author>
<name><first>Mortimer</first><last>Snerdly</last></name>
<email address='mort@surgery.com'/>
</author>
</authors>
</book>
</book>";
dynamic dx = new DynamicXml(books);
Console.WriteLine("Book list publication date='{0}'", dx.pubdate.Value);
Console.WriteLine(" Book count='{0}'", dx.book.Count);
Console.WriteLine(" first book title='{0}'", dx.book[0].title.Value);
Console.WriteLine(" first book price='{0}'", dx.book[0].price.Value);
Console.WriteLine(" first book authors count='{0}'", dx.book[0].author.Count);
// Output:
// Book list publication date='2009-05-20'
// Book count='1'
// first book title='Open Heart Surgery for Dummies'
// first book price='45.99'
// first book authors count='1'
http://blogs.captechconsulting.com/blog/kevin-hazzard/fluent-xml-parsing-using-cs-dynamic-type-part-1
Released
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Runtime: C#4 Variant Generics
interface IEnumerable<out T> : IEnumerable {
new IEnumerator<T> GetEnumerator ();
}
interface IEnumerator<out T> : IDisposable, IEnumerator {
new T Current {get;}
}
void Cat (IEnumerable<Stream> streams, Stream destination)
{
foreach (var stream in streams)
stream.CopyTo (destination);
}
Cat (new List<MemoryStream> {}, Stream.Null); // CS0266 in C#3
Cat (new List<FileStream> {}, Stream.Null); // CS0266 in C#3
Beta
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Runtime: C# < 5
// Old and busted
GetUserAsync ("migueldeicaza").ContinueWith (t =>
PostStatusAsync (t.Result, "Having an awesome time at #Xamarin Evolve!")
).Unwrap().ContinueWith (t => {
if (t.IsFaulted) {
ShowError (t.Exception.Flatten().InnerException);
return;
}
UpdateUI();
}, TaskScheduler.FromCurrentSynchronizationContext());
Released
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Runtime: C#5 Async
// New Hawtness
try {
var user = await GetUserAsync ("migueldeicaza");
await PostStatusAsync (user, "Having an awesome time at #Xamarin Evolve!");
UpdateUI();
}
catch (Exception ex) {
ShowError (ex);
}
Beta
Runtime: New Features
New default ARM ABI: armeabi-v7a (armv7)
F# support
Profiling [Beta!]
$ adb shell setprop 
debug.mono.profile log:sample
# Run app on device...
$ adb pull 
/data/.../files/.__override__/profile.mlpd
$ mprof-report profile.mlpd | less
•
•
•
Beta
Released
Binding Improvements
Expose more of the Java API
Embed Java libraries into assemblies
Build action: EmbeddedJar, EmbeddedReferenceJar
Java Library Project support
project.properties file
(Build action: LibraryProjectProperties)
library.zip file
(Build action: LibraryProjectZip)
•
•
•
•
•
•
Beta
Released
Released
What’s new in App Packaging?
Native library remapping (provide .dll.config)
Bundle assemblies into native code
Satellite Assemblies
Environment support (Build action: AndroidEnvironment)
# Comments
ENV_VAR=env-value
debug.mono.log=gref
debug.mono.env=MONO_LOG_LEVEL=debug
•
•
•
•
Released
Beta
Beta
Packaging: Library Resources
Library project assemblies may contain:
Android Resources (Build action: AndroidResource)
Native libraries (Build action: EmbeddedNativeLibrary)
Problem: default Library template may not support Android
Resources.
Solution: Hack it
Create a new Android Application project
Edit .csproj
Remove <AndroidApplication/> element.
Reopen project.
•
•
•
•
•
1.
2.
3.
4.
Beta
Released
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Packaging: [Export]
<!-- ResourceslayoutMain.axml -->
<Button
android:id="@+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:onClick="MyButton_OnClick" />
// MyActivity.cs
namespace MyApp {
public partial class MyActivity : Activity
{
[Java.Interop.Export]
public void MyButton_OnClick (View view)
{
((Button) view).Text = "clicked!";
}
}
}
Released
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Packaging: AndroidInterfaceDescription
// AIDL
package com.android.vending.billing;
import android.os.Bundle;
interface IMarketBillingService {
/** Given the arguments in bundle form, returns a bundle for results. */
Bundle sendBillingRequest(in Bundle bundle);
}
// C# generated code
interface IMarketBillingService : Android.OS.IInterface {
Android.OS.Bundle SendBillingRequest (Android.OS.Bundle bundle);
}
abstract class IMarketBillingServiceStub : Binder, IInterface, IMarketBillingService {
public abstract Bundle SendBillingRequest (Bundle bundle);
public partial class Proxy : Java.Lang.Object, IMarketBillingService {}
}
Released
Unified Components
Component Assembly may contain:
ECMA CIL (code)
ECMA Resources (Build action: EmbeddedResource)
Android Resources (Build action: AndroidResource)
Native libraries
Allows entire components to be shipped as single assembly, like
Xamarin.iOS
•
•
•
•
•
•
Released
Released
Released
Beta

What's new in xamarin.android, Jonathan Pryor

  • 1.
  • 2.
    What’s in Xamarin.Android IDE Runtime Javalibrary binding Packaging Unified Components • • • • •
  • 3.
    Visual Studio Layout Editor Non-ModalDeployment Target Selection • • • Released
  • 4.
    Xamarin Studio Layout Editor RazorHTML Generator • • Released
  • 5.
    Runtime: New Foundation Mono3.0 base, includes most .NET 4.5 APIs Stream.ReadAsync(), System.Net.Http.dll “Breaking” Change on OS X: new Java.Lang.Object() // CS1540 Xamarin.Android ≤ 4.6: “Silverlight” based Xamarin.Android ≥ 4.7: .NET 4.5-based - System.Configuration • • • • • Beta
  • 6.
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Runtime: C#4 Dynamic varbooks = @"<books pubdate='2009-05-20'> <book price='45.99' title='Open Heart Surgery for Dummies'> <authors> <author> <name><first>Mortimer</first><last>Snerdly</last></name> <email address='mort@surgery.com'/> </author> </authors> </book> </book>"; dynamic dx = new DynamicXml(books); Console.WriteLine("Book list publication date='{0}'", dx.pubdate.Value); Console.WriteLine(" Book count='{0}'", dx.book.Count); Console.WriteLine(" first book title='{0}'", dx.book[0].title.Value); Console.WriteLine(" first book price='{0}'", dx.book[0].price.Value); Console.WriteLine(" first book authors count='{0}'", dx.book[0].author.Count); // Output: // Book list publication date='2009-05-20' // Book count='1' // first book title='Open Heart Surgery for Dummies' // first book price='45.99' // first book authors count='1' http://blogs.captechconsulting.com/blog/kevin-hazzard/fluent-xml-parsing-using-cs-dynamic-type-part-1 Released
  • 7.
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Runtime: C#4 VariantGenerics interface IEnumerable<out T> : IEnumerable { new IEnumerator<T> GetEnumerator (); } interface IEnumerator<out T> : IDisposable, IEnumerator { new T Current {get;} } void Cat (IEnumerable<Stream> streams, Stream destination) { foreach (var stream in streams) stream.CopyTo (destination); } Cat (new List<MemoryStream> {}, Stream.Null); // CS0266 in C#3 Cat (new List<FileStream> {}, Stream.Null); // CS0266 in C#3 Beta
  • 8.
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Runtime: C# <5 // Old and busted GetUserAsync ("migueldeicaza").ContinueWith (t => PostStatusAsync (t.Result, "Having an awesome time at #Xamarin Evolve!") ).Unwrap().ContinueWith (t => { if (t.IsFaulted) { ShowError (t.Exception.Flatten().InnerException); return; } UpdateUI(); }, TaskScheduler.FromCurrentSynchronizationContext()); Released
  • 9.
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Runtime: C#5 Async //New Hawtness try { var user = await GetUserAsync ("migueldeicaza"); await PostStatusAsync (user, "Having an awesome time at #Xamarin Evolve!"); UpdateUI(); } catch (Exception ex) { ShowError (ex); } Beta
  • 10.
    Runtime: New Features Newdefault ARM ABI: armeabi-v7a (armv7) F# support Profiling [Beta!] $ adb shell setprop debug.mono.profile log:sample # Run app on device... $ adb pull /data/.../files/.__override__/profile.mlpd $ mprof-report profile.mlpd | less • • • Beta Released
  • 11.
    Binding Improvements Expose moreof the Java API Embed Java libraries into assemblies Build action: EmbeddedJar, EmbeddedReferenceJar Java Library Project support project.properties file (Build action: LibraryProjectProperties) library.zip file (Build action: LibraryProjectZip) • • • • • • Beta Released Released
  • 12.
    What’s new inApp Packaging? Native library remapping (provide .dll.config) Bundle assemblies into native code Satellite Assemblies Environment support (Build action: AndroidEnvironment) # Comments ENV_VAR=env-value debug.mono.log=gref debug.mono.env=MONO_LOG_LEVEL=debug • • • • Released Beta Beta
  • 13.
    Packaging: Library Resources Libraryproject assemblies may contain: Android Resources (Build action: AndroidResource) Native libraries (Build action: EmbeddedNativeLibrary) Problem: default Library template may not support Android Resources. Solution: Hack it Create a new Android Application project Edit .csproj Remove <AndroidApplication/> element. Reopen project. • • • • • 1. 2. 3. 4. Beta Released
  • 14.
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Packaging: [Export] <!-- ResourceslayoutMain.axml--> <Button android:id="@+id/myButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:onClick="MyButton_OnClick" /> // MyActivity.cs namespace MyApp { public partial class MyActivity : Activity { [Java.Interop.Export] public void MyButton_OnClick (View view) { ((Button) view).Text = "clicked!"; } } } Released
  • 15.
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Packaging: AndroidInterfaceDescription // AIDL packagecom.android.vending.billing; import android.os.Bundle; interface IMarketBillingService { /** Given the arguments in bundle form, returns a bundle for results. */ Bundle sendBillingRequest(in Bundle bundle); } // C# generated code interface IMarketBillingService : Android.OS.IInterface { Android.OS.Bundle SendBillingRequest (Android.OS.Bundle bundle); } abstract class IMarketBillingServiceStub : Binder, IInterface, IMarketBillingService { public abstract Bundle SendBillingRequest (Bundle bundle); public partial class Proxy : Java.Lang.Object, IMarketBillingService {} } Released
  • 16.
    Unified Components Component Assemblymay contain: ECMA CIL (code) ECMA Resources (Build action: EmbeddedResource) Android Resources (Build action: AndroidResource) Native libraries Allows entire components to be shipped as single assembly, like Xamarin.iOS • • • • • • Released Released Released Beta