Recently I’ve had the opportunity to dive deeper and deeper into the Xamarin.Forms platform. At first glance it seems to be a bit overwhelming with all the differences and setup modules you need to get up and running. Forget about managing Activities (Android) and pushing UIControllers on the stack (iOS), with Xamarin.Forms we’re able to get at the heart of what we care about: the content itself.
At the beginning of the project I began to experiment with all the controls that Xamarin.Forms has available, which you can find here. In particular I found my self using the ListView with and “ImageCell” type. This was working out GREAT, showing an employee like directory for the company, but one day after an update with Xamarin.Forms did everything seem to turn bad.
Debugging became a headache and found myself struggling with an exception that I simply could not get to the bottom, since the exception was being thrown from within Xamarin.Forms’s Platform. What made the situation even more interesting the fact it was only happening on Android. So, the first thing I did (as any other developer pulling his hair out) was go to Stack Overflow and the Xamarin Forums in search for some assistance. Little to my knowledge, that this exception wasn’t a very common occurrence.
05-13 08:03:16.143 E/mono (13153): Unhandled Exception: 05-13 08:03:16.143 E/mono (13153): System.ArgumentException: 'jobject' must not be IntPtr.Zero. 05-13 08:03:16.143 E/mono (13153): Parameter name: jobject 05-13 08:03:16.143 E/mono (13153): at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00010] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:563 05-13 08:03:16.143 E/mono (13153): at Android.Widget.AdapterView.set_OnItemClickListener (IOnItemClickListener value) [0x0005a] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Widget.AdapterView.cs:1031 05-13 08:03:16.143 E/mono (13153): at Xamarin.Forms.Platform.Android.ListViewAdapter.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 05-13 08:03:16.143 E/mono (13153): at Java.Lang.Object.Finalize () [0x00051] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:62
I did happen to find a report in Xamarin’s Bugzilla, here. But no one had responded yet (May 13, 2015) and considering the initial bug was reported 01-08-2015 by a Mr. David Johnson. I took to other means, since Xamarin seemed to have forgotten to update the post. I know how bugs can get lost in Bugzilla whether you’re a small startup company or a big enterprise, it happens. Anyways, I sought out my Business representative Ian, describing my issue, where I’ve been looking for help and even added the StackTrace for convience.
Ian was able to forward the email to Michael at the “Forms” division. Who was a delight to work with. We communicated back and forth and I eventually sent him a copy of the current source code with two videos showing how to replicate the issue on an actual device, emulator, steps, and the device information that is being used for debugging.
Within a day of sending the solution and all the additional information I had, Michael was able dig and confirm that there was a fix pushed out to NUGET back in April but was release in a pre-release version (Xamarin.Forms 1.4.3-pre2). Naturally, I fired up Visual Studio, then Nuget Manager Console and installed the package. Upon successful installation, I deployed the app to my phone, patiently waiting and hoping for no new run time exceptions to pop up, I was delighted when my directory opened and I could aggressively scroll without any problems.
So at the end of the day, I was able to finalize my build, push it out to Google and Xamarin’s Support Team saved the day after hours spent on this problem, which was an actual problem within the Platform itself.
Therefore, if you have an issue don’t be afraid to contact the Support Channels over at Xamarin. If you have a business account, contact your representative; if you’re an Indie developer contact “android at xamarin.com” or “ios at xamarin.com”
On to the next hurdle!