Bug 21785 - Crash in MediaPickerActivity.OnCreate
Summary: Crash in MediaPickerActivity.OnCreate
Alias: None
Product: Mobile API (Preview)
Classification: Xamarin
Component: Xamarin.Android ()
Version: Preview 0.6.3
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bill Holmes
Depends on:
Reported: 2014-08-03 07:43 UTC by Jens
Modified: 2017-05-24 22:49 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jens 2014-08-03 07:43:00 UTC
we receive crashreports, that our app crashes in the MediaPickerActivity.OnCreate () method with a null pointer exception.

Please note that we are using Xamarin.Mobile version 0.7.1, but that version can not be chosen here in the bug reporter...

Below you can find the full stack trace as displayed in the hockeyapp interface. 
Please note, that the device is called "Full Android on Emulator", so I guess the hardware might not be configured or so... 
Whatever, the code should not crash, even in that strange emulator... ;)

Package: de.appnotize.letmetalk
Version: 118
Android: 4.1.1
Manufacturer: unknown
Model: Full Android on Emulator
Date: 8/2/2014 9:28:29 PM

System.NullReferenceException: Object reference not set to an instance of an object
	at de.appnotize.letmetalk.Xamarin.Media.MediaPickerActivity.OnCreate(Android.OS.Bundle.args:1337)
	at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(intptr_intptr_intptr.args:1337)
Comment 1 Jens 2014-08-25 16:52:51 UTC
a current crash, probably the same:

Package: de.appnotize.letmetalk
Version: 127
Android: L
Manufacturer: asus
Model: Nexus 7
Date: 25/08/2014 19:13:26

System.NullReferenceException: Object reference not set to an instance of an object
	at de.appnotize.letmetalk.Xamarin.Media.MediaPickerActivity+<>c__DisplayClass2.<GetMediaFileAsync>b__1(System.Threading.Tasks.Task`1_t.args:1337)
	at System.Threading.Tasks.TaskActionInvoker+FuncTaskInvoke`2[System.Tuple`2[System.String,System.Boolean],Xamarin.Media.MediaPickedEventArgs].Invoke(System.Threading.Tasks.Task_owner__System.Object_state__System.Threading.Tasks.Task_context.args:1337)
	at System.Threading.Tasks.Task.InnerInvoke(.args:1337)
	at System.Threading.Tasks.Task.ThreadStart(.args:1337)
Comment 2 Jens 2014-09-30 04:15:25 UTC
i have posted more informations about the second crash at the forums.
It is probably the problem that some picker apps return the wrong Result value.


I would be happy about some work arround, as this is by far our top crasher now :(
Comment 3 Matthew Leibowitz 2017-05-24 22:49:36 UTC
This problem appears to be related to the way various eventing mechanisms are returned and handled. I would suggest having a look at the "Xam.Plugin.Media" plugin, which offers the same functionality, but with a more robust API.


Although I have not been able to reproduce this problem myself with the later versions of the plugins, it may just be the case that my device is returning the correct values. It may have been some bug somewhere in Android or the default Android apps.

If this is still an issue with the plugin, then feel free to open a new issue, and we will take a look:

This folloows on to the fact that the Mobile API is being deprecated in favor of various plugins (which have the equivalent/same API):
 - Contacts: https://www.nuget.org/packages/Xam.Plugin.Contacts
 - Geolocator: https://www.nuget.org/packages/Xam.Plugin.Geolocator
 - Media: https://www.nuget.org/packages/Xam.Plugin.Media

This plugin model has several advantages:
 - Each plugin is independent, and can be updated as such
 - It is no longer an all-or-nothing package
 - Plugins can be mixed/replaced with other plugins that offer similar features

Thanks for using the Mobile API, and we hope that the new plugin model will enable you to produce even better mobile apps.