Missing NETStandard.Library when create Xamarin.Forms project - xamarin.forms

When I create a new Xamarin.Forms project I got the yellow triangle telling me that I am missing some packages.
Here is what I did:
I reinstalled Visual studio 2017 (I am using version 15.8.9).
If I re-open the project, it's just gone. There is no SDK under the Dependencies anymore.
I used Nuget Package Manage console to try to install the missing library, but nothing happened.
So I would like to hear you guy's opinions. Thank you.

So I figured out the solution. I updated my windows 10 to the newest version and the problem solved!

Came across this issue.
Created a new xamarin forms project using netstandard and got broken references.
Updating all packages in nuget solved the issue.
First build after updating package can take a little bit if xamarin decides that it needs to update its packages.

Related

Error Message: Unable to resolve interface type > 'Android.Gms.Common.Apis.GoogleApiClient/IConnectionCallbacks'

I am a new Xamarin programmer. I was building an application via the simulator in Visual Studio 2017 for Mac and one day I saw the android version would not build. Since I was doing development primarily for iOS I procrastinated and pushed it for later. I now have an Android device to test on but I am getting this message:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3):
Error XA4204: Unable to resolve interface type
'Android.Gms.Common.Apis.GoogleApiClient/IConnectionCallbacks'. Are
you missing an assembly reference? (XA4204) (prayupapp.Droid)
I saw that the Google Play Store location services nuget used that so I even installed that Nuget and it still can't find that one reference. As a non android person I have no clue how to begin debugging this. Its crashing in Java here:
ResolvedAssemblies="#(_ResolvedAssemblies)"
Can someone point me in the right direction as to how to solve it?
I fixed this issue. You should be getting this issue because you have multiple versions of the GooglePlayServices in your Android project.
In my case, I had a Nuget package called SimpleLocation which was using an old version of GooglePlayServices (29.0.0.2). I updated this package (SimpleLocation) to its latest version which was using GooglePlayServices 60.1142.1 and the solution is building successfully now.
Have a look at the error message provided by Visual Studio and find the name of the Nuget package which is using an old version of the GooglePlayServices... in my case was SimpleLocation... Remove this Nuget package and comment out the code using this package and try to build your solution again.
I hope it helps.

Xamarin.iOS project: CS1703: Multiple assemblies with equivalent identity have been imported

I've got a cross platform (iOS and Android) Xamarin solution using .NET Standard 2.0. The solution is being built by Visual Studio 2017 (I've tried both the current and preview versions). The Forms and Android projects build fine. However, the iOS fails to build, with the following error:
1>CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\newuser.nuget\packages\system.reflection.emit\4.3.0\ref\netstandard1.1\System.Reflection.Emit.dll' and 'C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll'. Remove one of the duplicate references.
I've tried many work arounds as described here:
oren.codes
www.hanselman.com
github.com/NuGet
Unfortunately none of these suggestions work. I have also tried to add the System.Reflection.Emit nuget package directly to the Forms and/or to the iOS projects directly. This doesn't work either. Note that originally, the The System.Reflection.Emit package wasn't referenced directly by anything in the solution. It is being pulled in by the following nuget packages which are being explicitly referenced:
Acr.DeviceInfo (5.0.5)
akavache (6.0.0-alpha0038)
AutoMapper (6.2.2)
Microsoft.Identity.Client (1.1.1-preview0040)
Newtonsoft.Json (10.0.3)
Finally, I have tried the update-package -reinstall command in the package console to reinstall all packages for the iOS project. This doesn't work either.
-- update
Just to make this clear, neither the Xamarin Forms or the Xamarin iOS project directly reference System.Reflection.Emit. That package is being pulled in as a dependency of other nuget packages, just from packages that are installed into the Xamarin Forms project. I have confirmed all of the dependencies that are referenced by Nuget, are using the same version. See these screenshots:
It seems to me that the problem (as the error says) is that there is an old version of System.Reflection.Emit that was installed by Visual Studio. However, I can't find a way of ignoring it and using the version of System.Reflection.Emit instead. As I've said above, I have tried to use a project.json file in the Xamarin.iOS project, and manually ignoring, but this doesn't work.
Does anyone else have any ideas?
As an aside, I notice that this bug is still open for Xamarin.
Xamarin Bugs
Managed to get this resolved thanks to an answer by #DirkWilhem on Xamarin Forums site.
Basically, add this to your Xamarin iOS project's .csproj file, with the other PackageReference nodes:
<PackageReference Include="System.Reflection.Emit">
<Version>4.3.0</Version>
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
Of course you need to make sure the nuget package has been added to the iOS package first.
Xamarin Forums discussion
After spending hours trying to resolve this myself I may have found a solution. Although it does feel wrong, it has got me past the issue.
Moving/Deleting the Xamarin.iOS version of System.Reflection.Emit.dll has solved the build problem for me and enabled me to deploy and run my app on a device. I don’t know what side effects it might have so will need more testing but I thought I’d share what’s worked for me so you can test it as well.
I was running on macOS Visual Studio 2017 but switched over to Windows to try and fix and first fixed on there then tried same approach on macOS and it worked as well.
On windows, go into the following directory and move the System.Reflection.Emit.dll somewhere else (you could just straight up delete it but I wanted to keep a copy I case this has some undesired effects down the track):
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades
On mac the following directory has it:
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades
Like I say, it feels wrong but for now it’s got me past an issue that’s had me blocked for a couple of days so willing to just move on and hope there’s no side effects. I’d be interested to know your experience with it and if you come across anything else for the future too.
I’ll post this same comment on the Xamarin forums post (https://forums.xamarin.com/discussion/120814/xamarin-ios-project-cs1703-multiple-assemblies-with-equivalent-identity-have-been-imported) as well for future reference.
I had the same issue around a custom Nuget packages that we created and consumed in a separate project. We got around this issue by removing the automatic Nuget building checkbox in the "options" for the project. This does add the extra step of "Create Nuget Package" but one we pushed it to our Nuget repo and consumed it in our project, the errors vanished.
The problem showed up when we updated the sub-projects from PCLs to .netstandards (2.0).

Xamarin.Forms cannot update Xamarin.Forms Package from version 2.3.4.270 to 2.4.0.282

I'm trying to update a project to the newest version of Xamarin Forms and I'm getting an error. The error is the following
Unable to resolve dependencies. 'Xamarin.Android.Support.Design 25.4.0.2' is not compatible with 'Xamarin.Forms 2.4.0.282 constraint: Xamarin.Android.Support.Design (= 23.3.0)'.
Although the error message is obvious, it's strange that the new Xamarin.Forms package needs an older version of Xamarin.Android.Support.Design.
So, I created a new project and I saw that the versions in the new project are:
Xamarin.Forms 2.4.0.282 and Xamarin.Android.Support.Design 25.4.0.2 (!)
That's odd. The new project contains the version 25.4.0.2 Xamarin.Android.Support.Design. The old project rejects the update because it contains that version of Xamarin.Android.Support.Design. Doesn't make much sense.
So, the question is Why, am I getting this error and why I cannot update to the new version of Xamarin.Forms?
Try update your android support libraries first and then update to the latest xamarin forms 2.4.0
You're getting the error because Xamarin does not use latest versions of those android support libraries. You can see that when you install Xamarin.Forms package (Nuget-Manager: update only Xamarin.Forms), if it depends on newer versions of android support packages it will automatically update them.
So basically as long as Xamarin.Forms does not use latest android packages, they will always show 'update available' but when you update them, they're not compatible with Xamarin.Forms anymore.
Edit:
Sometimes it seems deleting packages and bin/obj folders is not enough.
If found this link with instructions for deleting nuget cache.
Fixing Xamarin.Android build errors

Xamarin SQLite "This is the 'bait'"

I follow this guide trying to create a SQLite database to my proyect. But always got same error, doing the exactly steps of the article.
System.Exception: This is the 'bait'. You probably need to add one of the SQLitePCLRaw.bundle_* nuget packages to your platform project.
Have you added the SQLite package to all your projects? You need to add it to the app projects as well as the PCLs.
This is what the error is telling you. It uses a trick called 'bait and switch' whereby it installs a dummy assembly in the PCL with a particular interface, and in the Android and iOS apps it installs a platform specific assembly with an identical interface that actually does the interactions with the database. The idea is you code against the PCL, but at run time the platform specific version of the library is used. You can read more about this pattern at https://web.archive.org/web/20161209075521/http://log.paulbetts.org/the-bait-and-switch-pcl-trick/
Essentially though, this error is telling you that you haven't installed the NuGet package in your platform-specific projects.
I was experiencing this issue despite following the instructions in the error message and installing the missing library.
A clean & rebuild solved it
I had installed the packages (SQLite-net PCL) but I uninstalled them, then reinstalled. And then I cleaned the solution and rebuilded it and now it works.

Xamarin.Forms version

When I create a new Xamarin.Forms project within Visual Studio it uses an old version of the Xamarin.Forms DLL (v2.0.0.6482). In nuget theres an update available to v2.3.0.107.
Why is an old version being used on project creation?
Im on the latest Visual Studio 2015 update and Xamarin version.
Thanks in advance
This is expected since the Forms templates that ship with Xamarin for Visual Studio are not updated as frequently as the package itself. You can go ahead and update the packages to the latest version available on NuGet. Just make sure to update the Forms package in all the projects to the same version.
Note though, only update the Forms package inside the Android project and not the Android Support packages. Forms will also update those to the correct versions needed in order to avoid compatibility issues.
Ok, sounds like it is an issue for a few people.
I have gotten it working with the help of a friend!
It's working fine for me now; I followed the steps below:
Start a new Xamarin.Forms portable project
Uninstall all Xamarin nugets, clear the packages folder (others will be downloaded)
Close VS 2015
Clear the C:\Users_[Username]_\AppData\Local\Xamarin\zips folder, these will be downloaded automatically as needed.
Open the project
Update nugets then install Xamarin.Forms 2.0.0.6490, this should get the relevant version of dependencies for the android project (ie Xamarin.Android.Support.x). This will be v23.0.1.3, even though an update exists, as MatPag stated, it is not yet compatible.
Build.
This will take a long, long time, as the Xamarin\zips folder will be re-populated so a quite hefty file will be downloaded.
Might complain again, clean, save then reopen.
This is will definitely work fine

Resources