Eels Fan
Eels Fan

Reputation: 2063

Unable to add Json.Net to Portable Class Library with MonoDroid and MonoTouch

I don't understand this post - http://slodge.blogspot.co.uk/2013/01/almost-portable-binaries.html

I'm still slightly confused. Are you saying that if we choose to use something like Json.Net in our app, we need to use a version specifically for MonoDroid and another specifically for MonoTouch? Currently, I have a Portable Class Library that contains my view models. My view models rely on Json.

When I attempt to manually add a reference to the NewtonSoft library included with MvvmCross, I get a compile-time error that says: "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)"

If I attempt to add Json.Net via NuGet, I receive an error that says: "Successfully installed 'Newtonsoft.Json 5.0.3'. Successfully uninstalled 'Newtonsoft.Json 5.0.3'. Install failed. Rolling back... Could not install package 'Newtonsoft.Json 5.0.3'. You are trying to install this package into a project that targets 'portable-win+net45+MonoAndroid16+sl40+net10+wp71', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."

What is going on?

Upvotes: 0

Views: 1587

Answers (1)

Stuart
Stuart

Reputation: 66882

The situation with PCLs inside the xamarin products is rapidly evolving - proper pcl support should be available within a few weeks, and there are also big mono2->mono3 changes occurring.

Until these changes are a bit more complete, the situation is:

  • you will probably be able to use existing profile 2 and profile 104 PCLs on droid as binaries

  • you may get away with using PCL binaries on iOS - but it's less likely

  • it is safest to rebuild your PCLs for each platform

Specifically for json.net I have bundled a version with mvx for several months and not had a problem on iOS or touch, but I have not used every option and code path - so there may be gremlins lurking in this approach.


For nuget support for droid and touch, dsplaisted added this to nuget 2.5 (a hero!) - but so far the only package author i know who has added support for xamarin nuget targets is me - please do encourage other authors to join in - maybe by sending them a pull request?

Upvotes: 1

Related Questions