When we are trying to build a xamarin forms project in release mode, we are getting the error:
C:\\Program Files (x86)\\MSBuild\\Xamarin\\Android\\Xamarin.An
I ended up getting this error after changing the Android target version to 9.0. What I noticed is that in the packages.config
of the Android project, all the packages were still targeting monoandroid81
instead of monoandroid90
.
I solved it by just reinstalling all NuGet packages. This can be done quite easily through the Package Manager Console in Visual Studio by entering:
Update-Package -Reinstall
I recommend taking a backup first, though.
After that all the packages were targeting the correct version and the compilation errors were gone.
I changed the Linker properties > Linking from Sdk Assemblies Only to Sdk and User Assemblies for the Release configuration.
Apparently, this is a known issue: Xamarin Forms needs the TargetAndroidVersion to be 21. (In the config GUI, this is entitled "Compile using Android version:")
Change linking to old mono android to new mono android. It worked for me. I changed from Monoandroid 8.0 to Monoandroid 9.0 of some dll's like Xamarin.Android.Platforms etc..
In my chase I have changed the linker property ( Linker --> Linking ) to 'None'. I am using visual studio 2017 RC
Jus I changed linking from "NONE" to "sdk and users assembly" and I ran my solution, and the issue has been solved. after that you can change "sdk and users assembly" to "NONE" and run your project without any issue.
But the release file size may be will be change.
enter image description here