How can I add libraries to Xamarin Mono for Android project in VS2010? - rest

I am working on a mono for Android application (my very first) that consumes a web api. In the documentation at xamarin.com there are examples on using different libraries such as RestSharp and Json.Net.
However, when I try to install these libraries via Nuget in my VS2010 project it failes with the following message:
Install failed. Rolling back... Could not install package
'Newtonsoft.Json 4.5.9'. You are trying to install this package into a
project that targets 'MonoAndroid,Version=v2.2', but the package does
not contain any assembly references that are compatible with that
framework. For more information, contact the package author.
How can I include such libraries in my project?
Thanks in advance.
Erwin

This error message indicates those libraries are not compatible with Mono for Android. You should ask the manufacturer of the libraries if they have a MfA compatible version. If you have the source code of the libraries you could also try to make a MfA library, using linked source files, yourself.

Not sure if you've tried this but if you're using xamarin studio and right click the component folder in your Android app project choosing add component should be able to solve your problem. This will add a reference to the component that is added. Components seem like they are mono compatible packages and what's good for your case is that there are components for both RestSharp and Json.Net:
https://components.xamarin.com/view/restsharp
http://components.xamarin.com/view/json.net/

Related

VS2017 Setup project for .NET 4.7.2

Having configured a Setup project for my .NET 4.7.2 codebase the Detected Dependencies shows up with a netstandard.dll.
Is there anyway to tell where this might be coming from?
Again it's just an entire 4.7.2 based code with that target Framework chosen.
The Prerequisites Page has the 4.7.2 chosen and the Launch condition has 4.7.2.
What could be causing the netstandard.dll to be included in the project output?
What could be causing the netstandard.dll to be included in the
project output?
First, thanks to magicandre1981 for all his help.
You have referenced a net standard nuget packages in your Net Framework 4.7.2 project. And because of the special nature of the package, it needs to refer to netstandard.dll as a runtime environment.
Although Net Frameowork 4.7.2 optimizes the build output file, so netstandard.dll cannot be shown in the project outputpath, but in fact the project will still use it at runtime.
But for the setup project, there is no such feature. Using the netstandard nuget package, all references will be displayed in Detected Dependencies including netstandard.dll.
In addition, Net Standard 2.0 is compatible with Net Frameowork 4.7.2, and you can refer to this document.

Visual Studio 2017: Package Restore failed, Rolling back Package changes for 'Projectname'

Added the new Package using Package Manager console or manage nuget packages in Project it's not added project it's Throw below Error.
I was Check some Links Not give proper reason. why this problem in coming in vs2017
Anyone Know Share the knowledge.
Thanks in Advance
Visual Studio 2017: Package Restore failed, Rolling back Package changes for 'Projectname'
You could not install the package exceldatareader.dataset to the UWP project. That because this package only have the .NET Framework assemblies, which is not compatible with UWP project. You can download that package from nuget.org, then open it, you will find this package only have the assemblies for .NET 2.0 and .NET 4.5:
So this package is not compatible with UWP project, you can find the error message in the output window when you install it to the UWP project:
Hope this helps.

How do I know if platform projects also require a NuGet package

In my solution I have a PCL project and two other projects, each for different platforms.
Sometimes a NuGet package used in PCL require installing it to the platform project as well, otherwise things will crash at runtime.
When I install the NuGet package, how do if it's also required to install it to the platform projects?
For example, it's not clear to me if Microsoft.Net.Http requires also installation in Xamarin Android project or not. This is just an example.
Or, I don't know if SQLite.Net-PCL requires it to be installed on platform projects as well.
Things you can do:
Read the documentation provided by the NuGet package author. Either from a project web site or in the description for the NuGet package.
Use your favourite search engine for examples of how to use that NuGet package.
If there are multiple NuGet packages that are named after the platform then that gives you an idea that the PCL NuGet package might not work in the platform specific project.
Have a look inside the NuGet package using something like the NuGet Package Explorer available on Windows. If the NuGet package has lib directories that are platform specific as well as a PCL directory then it will need to be installed in the platform specific project.
Run your application and see if it works.
Taking Microsoft.Net.Http as an example. The documentation does not really say explicitly. If you search the internet you can find a blog post or two that mentions that you have to install it into your platform specific project.
If you take a look inside the Microsoft.Net.Http NuGet package you can see it has several lib directories:
There are platform specific directories, such as MonoAndroid and Xamarin.iOS10 as well as PCL directories, such as portable-net45+win8. This suggests you should install it into all your projects.

Adding Prism reference in Xamarin PCL project breaks build on Windows Phone 8.1 and UWP

I'm using some of core Prism classes in PCL Project for Multi-platform app. Everything Is fine (I chcecked only on Android as I don't have a Mac) until I add Windows Phone 8.1 or Universal Windows 10 Project and configure them like Xamarin website tells. What I receive is:
Cannot resolve Assembly or Windows Metadata file 'Prism.dll'
Type universe cannot resolve assembly: Prism, Version=6.1.0.0,
Culture=neutral, PublicKeyToken=91a96d2a154366d8.
When I remove all Prism related thing from PCL the projects build, so I'm considering copying prism project into my solution. Or maybe should I reference Prism as a dll instead of nuget or what?
I always thought that nuget takes the job of picking the dll with proper target.
Edit: Xamarin.Froms ver: 2.0.0.6490 (in all projects now) VS 2015.
You can't use the current NuGet packages if using UWP because NuGet will add the wrong assemblies to your Xamarin.Forms project. NuGet doesn't know you are using a Xamarin.Forms app and adds the wrong assemblies. You need to add the references manually.
See this issue: https://github.com/PrismLibrary/Prism/issues/376

Could not install package 'NuGet.Client 3.2.0'

I'm working with RESTful webservice, getting error while adding package "System.Net.Http";
"The 'System.Net.Http 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.5.0'. "
So, to resolve above error i'm trying to install "NuGet client" from "Add Package" option in xamarin studio, but this time I'm facing another issue that is;
"Could not install package 'NuGet.Client 3.2.0'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10', 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."
please help to resolve this issue.
Xamarin Studio currently does not support NuGet 3. It is currently only supported in Visual Studio 2015.
It is not possible to upgrade Xamarin Studio so it supports NuGet 3 at this time. Installing the NuGet.Client NuGet package does not upgrade NuGet in Xamarin Studio.
I would instead look at using the Microsoft.Net.Http NuGet package which you can install into a portable class library project (PCL) and supports all Xamarin Android and Xamarin iOS projects.
I was able to grab a copy of System.Net.Http.dll from another project and manually add it as a reference to my Xamarin project. I put it in the packages folder and then browsed to it from the edit references dialog.
For people facing problem trying to add System.Net.Http...
I was able to solve the problem by using Microsoft.Net.Http instead of System.Net.Http. In Xamarin studio, Right click on your project > Add > Add NuGet Packages.. > search for "Microsoft Http Client Libraries" and click Add Package.