One of the most frequent requests we are getting from customers evaluating our Android DataGrid product, is support for Xamarin.

Finally, after a long period of research, and overcoming some of the technical hurdles with cross JNI method calls, we are pleased to announce, that we now have a Binding DLL ready for Xamarin!

This is a feature a a lot of you had been asking for. The task was not easy, we encountered a number of technical hurdles. Most of them were fairly basic, but here are some that took a little head scratching. 


1) First, when we used the Xamarin Binding Project, any RequestTask based class we had, failed to convert to C# with the following errro :

Error Message : Error CS0534: does not implement inherited abstract member 'Android.OS.AsyncTask.DoInBackground(params Java.Lang.Object[])' (CS0534) (XamarinStudioBindings)

Solution: Turns out, this is a bug with Xamarin - see . There are multiple solutions proposed, the one that worked for us was to change:

protected virtual string DoInBackground (params  string[] p0) to protected override Java.Lang.Object DoInBackground (params  Java.Lang.Object[] p0) in the generated class. 

2) Second, for some reason, when pasting text into Xamarin Studio in the grid_config.xml, we got this :

Error Message : org.xml.sax.SAXParseException: Unexpected token (position:TEXT @1:2 in

Solution : When opened in the HEX editor, there was indeed a wierd character at position zero. Removing the corrupt character from the file resovled this issue.

3) Finally, for those of you who are familiar with our API, the grid exposes a number of events, callback functions, etc. The problem is that with Xamarin C#, these methods are not exposed to the Android Callable Wrapper. This results in :

Error Message :  E/AndroidRuntime( 2506): Caused by: java.lang.NoSuchMethodException: m

Solution : The way to fix this is to add the Java.Interop.Export attribute to your code that gets called in xamarin [Export]. You will need to add Mono.Android.Export assembly to your References in your project. For example:


        public  void onChange(FlexDataGridEvent e){
            Toast.MakeText(this"Grid Selection Changed : Items selected : " + e.Grid.SelectedObjects.Count, ToastLength.Short).Show();


4) The issue with the above, is that for some methods, you will get this

Error XA4209: Failed to create JavaTypeInfo for class:due to System.NullReferenceException: Object reference not set to an instance of an object

Solution : Ensure that the return type, as well as the parameters all inherit from Java.Lang.Object. For example, instead of returning Integer from a method, return Java.Lang.Integer. 

This post In a future post, we will go over the actual usage of the library dll. This post was mainly designed for those poor folks who are in the same position as us, trying to make a Xamarin dll out of a fairly large Android Library Jar.