Xamarin - How to update Mono.Android version to resolve dependencies? - visual-studio

I'm trying to install a nuget package (Xamarin.Firebase.Firestore) which requires a newer version of Xamarin.GooglePlayServices.Basement (60.1142.0, I have 42.1021.1), which in turn requires me to update the xamarin.android.support packages. When I try to update those, I get this error
"Package Xamarin.Android.Support.Design 27.0.2 is not compatible with monoandroid80 (MonoAndroid,Version=v8.0). Package Xamarin.Android.Support.Design 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1)"
I've tried changing my target android version to 8.1, I've also updated my SDK as well as the build tools. I'm running Visual Studio 15.6.1. As a last ditch effort, I tried deleting the Mono.Android V8.0 reference and then adding a new reference to V8.1, but whenever I do so, Visual studio just ends up adding the reference with the path pointing to V8.0, even though the reference I added was clearly pointing to V8.1.
Anyone has a clue how to resolve this issue?

tried changing my target android version to 8.1
You need to change the Target Framework that is used to compile your android application, not the Target Android version (but assumably you would set these two to the same, read the Understanding Android API Levels link below.
Visual Studio for Windows:
Visual Studio for Mac:
Target Framework – Specifies which framework to use in building your application. This API level is used at compile time by Xamarin.Android.
Minimum Android Version – Specifies the oldest Android version that you want your app to support. This API level is used at run time by Android.
Target Android Version – Specifies the version of Android that your app is intended to run on. This API level is used at run time by Android.
Understanding Android API Levels
Manifest Entries:
Visual Studio for Windows:
Visual Studio for Mac:

Related

Xamarin forms build success but deploy failed

I receive this warning when ever I try to deploy my Xamarin.Froms app to any device or emulator. Also the deploy fails without any errors. I cannot run my app. Can Any one please help me?
The $(TargetFrameworkVersion) for Xamarin.Forms.Platform.dll (vv8.0)
is greater than the $(TargetFrameworkVersion) for your project (v7.1).
You need to increase the $(TargetFrameworkVersion) for your
project. App2.Android C:\Users\subas\source\repos\App2\App2\App2.Android\App2.Android.csproj
EDIT/UPDATE
Right now JDK9 and the Android SDK tools are not compatible with each other - thus Xamarin.Android does not work with JDK9.
Run the following to see the version of java you have installed:
java -version
If it reports something along the lines of java version "9.0.4" you have JDK9.
Specifically there's an issue with the apksigner. It's not using the -classpath switch that the JDK expects.
Easiest way to fix is to install the JDK8 and make sure your PATH is pointed at it.
This documentation gives a solid overview.
ORIGINAL
Sounds like the target Android framework in the project needs to be updated to point to the latest version of Android.
First - make sure you have the latest Android SDKs installed. Here's some documentation on that.
Once you have the latest - here is how to make sure you're targeting the latest - depending on the IDE you're using:
Visual Studio Mac
In the solution explorer, right click the Android project and select options.
Under the Build -> General node - select "Use latest installed platform" from the Target Framework dropdown.
Save everything, close the solution, restart VS-Mac
Visual Studio
Right click the Android project in the solution explorer and select properties
Under the Application node, select Use Latest Platform from the Compile Using Android Version dropdown.
Save everything, close the solution, restart Visual Studio

can't update or install any nuget packages in vs 2017

I just installed vs 2017 and wanted to run my project but i'm facing so many warning and errors so I realized I should update my xamarin.android nuget packages but I keep getting this error message below:
Severity Code Description Project File Line Suppression State Error Could not install package 'Xamarin.Android.Support.Animated.Vector.Drawable 27.0.2-preview1'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v8.0', 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. 0
Repairing vs didn't work; deleting nuget.config didn't work; I even changed the version in .csproj file, but when i load the project it goes back to v8.0.
Can anybody please help?
can't update or install any nuget packages in vs 2017
Just as Jon said, the latest nuget package Xamarin.Android.Support.Animated.Vector.Drawable 27.0.2-preview1, which requires MonoAndroid81 at minimum to install.
However, only the latest Preview (15.6 Preview 2) version of Visual Studio includes Android 8.1 support. As this moment, current release version is 15.5.4, preview release version is 15.6 Preview 2. So if you want use that nuget package the latest version 27.0.2-preview1, you need download the latest version of Visual Studio 15.6 Preview 2 and install Android SDK 8.1.
If switch to Visual Studio 15.6 Preview 2 is not your choice, you should not update that package to the latest version, just use the version 26.1.0.1.
Hope this answer more clear.
This requires MonoAndroid81 at minimum to install. You can use the current Preview which includes Android 8.1 support:
https://blog.xamarin.com/xamarin-android-now-double-stuffed-with-oreo-8-1/
For future reference, the support library has a major version that maps with the Android version it supports. In this case Support v27 = Android 8.1 (API 27)
When errors appear, clean your solution and rebuild it.
Also do something very basic, that what you are going to download is "accessible " in .Droid and that is not only in the Portable.
If you do not serve, and do not find a solution, you must start a new project, it would be advisable to install the latest SDK, etc.

Xamarin Android SDK Manager doesn't save locations

Using Visual Studio 2017 and Xamarin, I installed the Xamarin Android SDK Manager to replace the default Android SDK Manager, which is now deprecated.
Then I updated JDK to the current x64 version and, using the Xamarin SDK Manager, I installed the most recent version of Android NDK.
I now want to update the locations of these SDK's in the Xamarin Android SDK Manager, Locations tab like so:
Yet, every time I restart the tool, the locations are reset. It also keeps telling me there's 2 components to install, yet when I do, it doesn't complain about any failure.
I have tried running as Admin and cannot seem to figure out what is wrong. Log files seem to be non existent. Is there anyone who has the same problem and found a solution?
This was a bug and has been fixed in 0.1.76.
See https://bugzilla.xamarin.com/show_bug.cgi?id=58319 for details.
Download the newest version here: https://marketplace.visualstudio.com/items?itemName=Xamarin.XamarinAndroidSDKManager

Xamarin.Android version numbers seem inconsistent

To keep build tool version consistency, I want to manually upgrade Xamarin on my desktop as well as my CI build server (not to be confused with a Xamarin mac build host). Running auto-update only works if I upgrade all machines at the same time.
So I go to download, and I thin I need to download Xamarin.Android - latest version is 4.0.1. No revision number is given here.
The thing is, I did run an update from Visual Studio the other day, and according to the about dialog, I'm now running "Xamarin.Android 6.0.1.10":
Xamarin 4.0.1.89 (413372c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android 6.0.1.10 (e98e962)
Visual Studio plugin to enable development for Xamarin.Android.
I've heard that the v4.0.1 relates to the Visual Studio plugin (I use VS on my desktop).
IN addition, I don't use Visual Studio on my CI build server; instead I have Xamarin Studio. When I look at pending updates for that, it's offering "Xamarin 4.0.1.93" - presumably not a Visual Studio plugin for Android Studio?
Is Xamarin telling me I'm downloading "Xamrin.Android 4.0.1" when really I'm downloading "Xamarin v4.0.1.?" which contains "Xamarin.Android v6.x.x.x".
My end-game is that I would like to be sure of what versions of Xamarin components are involved when building using MSBuild.
If I need to do a legacy build, I would like the legacy build tool to be used.
Update: I have started tracking versions myself here
Xamarin support got back to me. My understanding is:
The version number in the dropdown seems to be that of the installer that bundles both Xamarin.Android and Xamarin.iOS. It is not the version of Xamarin.Android.
Build tool version: "Xamarin.Android performs the build, so this is what you are looking for."
You can find out roughly what version of "Xamarin.Android" is bundled with "Xamarin" from the "Xamarin" Release Notes. The top line says something like Xamarin 4.0 updates Xamarin.iOS 9.4 and Xamarin.Android 6.0 releases.
More info from Xamarin:
On Windows you cannot download separate installers for Xamarin.iOS and
Xamarin.Android.
The Xamarin.VisualStudio package (also referred to as just "Xamarin")
includes Xamarin.iOS and Xamarin.Android.
E.g., Xamarin 4.0.1.93 contains Xamarin.iOS 9.4.1.24 and
Xamarin.Android 6.0.1.10
The version number you see on the download page refers to the version
number of "Xamarin" - which, as above, includes Xamarin.iOS and
Xamarin.Android. This is the same when you are updating and see
"Xamarin 4.0.1.93" for example.
You need to install "Xamarin" even if you are using Xamarin Studio on
Windows as this includes Xamarin.Android.
and
We do issue separate installers for Xamarin.Android on OS X, so if you are able to use a Mac for your CI (e.g., with something like Jenkins), then this may be more viable.

Why would the following errors occur in Xamarin Studio on OS X but not in Visual Studio?

I'm trying to understand why I'm getting the following errors when running tests in Xamarin Studio 5.9.1 (build 3) on OS X.
System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
System.TypeLoadException : A type load exception has occurred.
All projects build successfully and the same tests run just fine in Visual Studio on Windows using the same solution.
I am seeing a warning when building the test project on OS X, despite having already installed and added the reference.
All projects referencing MyProject.fsproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.
I still don't know why Xamarin behaves differently than Visual Studio, but the root cause was that the test project was targeting .Net 4.5 whereas the main project was targeting .Net 4.0
Thanks to #7sharp9 for the help.
Different platforms (Android, iOS, Desktop) have different System.Net.Http.dll binaries - compiled from the same source, but each version references the mscorlib.dll (and other base-class libraries) from the platform it was built against.
This is not a problem when you use it in an application - Xamarin Studio will automatically pick the right version for you - but you can't use it in a Portable Class Library.
Microsoft initially implemented HttpClient as part of .NET 4.5, but then released a portable version of it (with a Windows-only license). If I understand this correctly, then that's mostly the same API as in .NET 4.5 plus a few minor additions (I think they added gzip compression, which Mono's version currently doesn't).
For Xamarin / Mono, all we need to do to create an open-source version of this library is to take our existing sources and compile them against the portable profile. I haven't tried this yet, but this could be as easy as editing the .csproj file and replacing the .
Also would suggest that you install HttpClient NuGet package
System.Net.Http.HttpClient is available directly from the latest version of Xamarin.
Simply check for updates from Xamarin Studio ;-)

Resources