3
votes

So I create a Forms solution, in my PCL project I add the NuGet Microsoft.WindowsAzure.Mobile.

When I run my Android project (which of course references the PCL project), I get:

[MonoDroid] UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: A Microsoft Azure Mobile Services assembly for the current platform was not found. Ensure that the current project references both Microsoft.WindowsAzure.Mobile and the following platform-specific assembly: Microsoft.WindowsAzure.Mobile.Ext.

Ok, fine, I add the Microsoft.WindowsAzure.Ext (by manually Edit References->Browse to the ..packages..Microsoft.WindowsAzure.Mobile.Ext assembly and add it) to my Android project, but then I get:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Xamarin.Auth.AndroidAccountStore/SecretAccount, Xamarin.Auth.Android, Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Xamarin.Auth.AndroidAccountStore/SecretAccount, Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (MyApp.Android)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Xamarin.Auth.FormAuthenticatorActivity, Xamarin.Auth.Android, Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Xamarin.Auth.FormAuthenticatorActivity, Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (MyApp.Android)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Xamarin.Auth.FormAuthenticatorActivity/State, Xamarin.Auth.Android, Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Xamarin.Auth.FormAuthenticatorActivity/State, Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (MyApp.Android)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Xamarin.Auth.WebAuthenticatorActivity, Xamarin.Auth.Android, Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Xamarin.Auth.WebAuthenticatorActivity, Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (MyApp.Android)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Xamarin.Auth.WebAuthenticatorActivity/State, Xamarin.Auth.Android, Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Xamarin.Auth.WebAuthenticatorActivity/State, Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (MyApp.Android)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Xamarin.Auth.WebAuthenticatorActivity/Client, Xamarin.Auth.Android, Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Xamarin.Auth.WebAuthenticatorActivity/Client, Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (MyApp.Android)

Seems to be some conflict with Xamarin.Auth?

How do I solve this?

2
I am not sure about Xamarin.Auth, but to use Azure Mobile Services you should add AMS from NuGet to PCL and from Component store to Android projectxakpc
Yes, @xakz, this is exactly what I have done.Magnus Johansson
i was able to reproduce this error. I think this is major problem, i expected to use Xamarin.Auth with Azure in not so distant future. I think you should post a bugreport bugzilla.xamarin.comxakpc
Hi, I'm a member of the mobile services team. The mobile services SDK for Xamarin uses Xamarin Auth internally, and it appears the problem is that Xamarin.Android won't allow two types with the same namespace from two different assemblies. I'll investigate what can be done in the SDK to remove the potential conflict.Paul Batum
Thanks @PaulBatum, in the mean time I did create a bug with Xamarin: bugzilla.xamarin.com/show_bug.cgi?id=21147Magnus Johansson

2 Answers

0
votes

I have manage to find a workaround. Create a Portable Class Library in which you add the nugget version of mobile services. In this way you can make a wrapper over the existing mobile services from the pcl. This clearly works and it the best solution till the bug is fixed. If you have any questions please feel free to ask.

0
votes

This error is resolved as of version 1.2.5 of the Mobile Services SDK.