Hi,
I am trying to use the MediaPicker available in XLabs 2.0.0 Stable, but keep running into an error whenever I try to access to the MediaPicker on an Android device. The error is as follows:
02-07 08:59:36.010 W/ ( 4680): Missing method GetString in assembly /storage/emulated/0/Android/data/MyApplication.Forms.Droid/files/.__override__/XLabs.Platform.Droid.dll, type Android.OS.BaseBundle
02-07 08:59:36.026 W/Mono ( 4680): The class Android.OS.BaseBundle could not be loaded, used in XLabs.Platform.Droid
I am using the latest stable release of XLabs (Core, Forms, IoC, Platform, Serialization) in both my PCL and my IOS and Driod projects.
In my mainactivity.cs (droid project) I have the following IOC setup code:
private void SetupIOC()
{
var resolverContainer = new SimpleContainer();
var app = new XFormsAppDroid();
app.Init(this);
resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice)
.Register<IDisplay>(t => t.Resolve<IDevice>().Display)
.Register<IDependencyContainer>(resolverContainer)
.Register<IXFormsApp>(app)
.Register<IMediaPicker>(t => t.Resolve<MediaPicker>());
Resolver.SetResolver(resolverContainer.GetResolver());
}
The .Register line was added after reading another post in this forum which suggested it might fix this problem (http://forums.xamarin.com/discussion/30857/appledevice-is-missing-in-xamarin-forms-labs-1-2-1-pre2).
In my View Model in my PCL library I have the following code:
var device = Resolver.Resolve<IDevice>();
mediaPicker = DependencyService.Get<IMediaPicker>();
This gets me a valid MediaPicker reference and is definitely not null. Fyi, I have also tried using the line referred to in the previous post:
mediaPicker = Resolver.Resolve<IMediaPicker>();
but this always results in a NULL value. After getting the MediaPicker, I execute the following code:
var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
{
DefaultCamera = CameraDevice.Front
});
This code (mediaPicker.SelectPhotoAsync) then throws an exception, and the above error message is what's output into the "output" tab of visual studio.
I have ensured that the Android manifest has the correct permissions (CAMERA, WRITE_EXTERNAL_STORAGE), and have confirmed that the same code executes fine on IOS. I am testing against the Nexus 7 (KitKat) emulator via Xamarin Android Player, but have tried a couple of different options all with the same results.
Am I doing something wrong, or is there a bug in XLabs?