The document summarizes new features in Xamarin.Android, including:
1) Runtime improvements such as support for C# 4 dynamics and generics, async/await, and profiling.
2) Better Java library binding and packaging support, including embedding Java libraries in assemblies.
3) Enhancements to application packaging like remapping native libraries, bundling assemblies into native code, and supporting resources in library projects.
4) The introduction of unified components that allow entire reusable components to be shipped in a single assembly.
5. 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
6. 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
7. 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
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
10. 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
11. 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
12. 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
13. 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
15. 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
16. 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