1
votes

I upgraded my Visual Studio version to 15.5.2 last night. Now I can no longer run Xamarin.Forms cross platform apps. They were working fine with no errors before.

When I create a project the option for .NET Portable Class Library is no longer available, and has been replaced with the .NET standard library option.

enter image description here

enter image description here

However the template project that visual studio creates doesn't work. It gives me all these errors. I don't know what to do to fix this, I tried installing the latest .NET Core SDK based on this answer

https://stackoverflow.com/a/45737766

but it had no effect.

1.

Severity Code Description Project File Line Suppression State Error The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0. Phoneword C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets 126

2.

Severity Code Description Project File Line Suppression State Error The "ResolveLibraryProjectImports" task failed unexpectedly. System.IO.FileNotFoundException: Could not load assembly 'Phoneword, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? File name: 'Phoneword.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName) at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection1 resolvedEnvironments) at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Phoneword.Android

.

EDIT: The following 4 errors (3 - 7) went away after I installed the Android 8 SDK from the Android SDK manager, then selected it in the 'Compile using Adnroid Version' option'

enter image description here

3.

Error NU1202 Package Xamarin.Android.Support.v4 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v4 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)

4.

Error NU1202 Package Xamarin.Android.Support.v7.CardView 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.CardView 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)

5.

Error NU1202 Package Xamarin.Android.Support.v7.AppCompat 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.AppCompat 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)

6.

Error NU1202 Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)

7.

Error NU1202 Package Xamarin.Android.Support.Design 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.Design 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)

2
Open command prompt and navigate to the folder Phoneword. Run dotnet --version to see what exactly is the .NET Core SDK on your machine. I cannot reproduce the error at all (but another related to Xamarin.Android).Lex Li
@LexLi the command output is .NET Command Line Tools (1.0.0-beta-001598)erotavlas
Clearly that's the culprit. People should use 2.x (2.1.2 for example) today, while you are using a 1.0.0 beta release (years old). Go to dot.net and download the latest SDK installer.Lex Li
@LexLi I went to the control panel and saw I have installed 1.0.0 as well as 1.0.3, and 2.1.2, and 2.1.3...so I'm going to try your suggestion but will uninstall all of them and reinstall just the latest one to see if that helps.erotavlas
Then check the folders to see if you have global.json left somewhere by mistake. If such a file exists and forces its sub directories to use the out-of-date SDK version, no doubt you won't get things done.Lex Li

2 Answers

2
votes

I noticed the target framework in the shared project settings was blank, probably targeting .NET standard library 2.0 which I think is not compatible with this project type.

enter image description here

enter image description here

I selected version 1.6 and after I did that the yellow warning symbol in the dependencies went away and a new dependency appeared for the .NET standard library SDK

enter image description here

1
votes

Try to change "Compile using Android Version" to 7.0 or 8.0 under Android project -> properties -> Application.