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.
Related
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.
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).
I try to use the SQLite in the VS2017 in a universal windows platform project. I follow the guidance to download the SQLite extension for VS2015 although my local machine environment is VS2017, maybe this is the root cause? Then I add the reference with SQLIte. After that I installed the SQLitePCL with nuget.
After the SQLite installed, I wanted to try to run a demo to see if it can work right. But I found I can't using the namespace (using SQLite.Net.Attributes;) which it necessary for my demo.
I did some search about the SQLite and VS2017, But didn't found too much about such circumstances. So I want to know if anyone ever met such problem and How can your fix that?
Or it just unavailable to using SQLite in VS2017? If yes, can I complier a newest version about this?
Thanks everyone who can give me some reply or suggestion about this issue.
But I found I can't using the namespace (using SQLite.Net.Attributes;)
It seems like SQLite.Net.Attributes is belong to the Nuget package SQLite.Net-PCL, not SQLitePCL, the one you are using. SQLitePCL does't contain SQLite.Net.Attributes. You may obtain the package that is not you attempt to use.
There're many Nuget packages for SQLite, some of them are older with long time no updating. For UWP app, I'd recommend you to follow this tutorial to use a SQLite database in a UWP app.
Im trying to create a Xamarin Forms App using the new Entity Framework Core. The app targets android 6.0 but my Emulator is running Android 7.0. I installed the following related Nuget packages on the android project:
Microsoft.EntityFrameworkCore --> 1.1.1
Microsoft.EntityFrameworkCore.Sqlite --> 1.1.1
When accessing my DbContext on Android a message will pop up telling: Detected problems with native libraries unauthorized access to "/system/lib/libsqlite.so".
This Xamarin forums thread suggests, that it's due to the native SqLite binaries are no longer supported (on Android 7?) and the common fix seems to be to switch to the SqLite.Net PCL.
However as Microsoft.EntityFrameworkCore.Sqlite depends on Microsoft.Data.Sqlite which in turn depends on the native SqLite package I cannot just replace this (or can I?)
Strangely enough, despite of the error message suggesting otherwise, the data access seems to work. At least migrations run and repeated writes to the database will create new Ids.
Of course I could just scrap EF Core but I guess a lot of people are looking into using it for Xamarin in the future. So it would be nice if anyone would find/know a fix.
I had the same problem. I have fixed this using the following libs: sqlite-net-pcl (version 1.2.0), SQLitePCLRaw.bundle_green, SQLitePCLRaw.core, SQLitePCLRaw.lib.e_sqlite3.android, SQLitePCLRaw.provider.e_sqlite3.android.
Matheus Souza had the right idea there. However installing SQLitePCL is only part of the answer. Here is how I eventually solved this:
DISCLAIMER: This is a kind of "You can do it but it isn't pretty"-solution. If you have the time, it's probably best to wait for the official Microsoft.EntityFrameworkCore.Sqlite 1.2.0 release.
This issue brought me on the right track. The new (unreleased) version of EntityFrameworkCore no longer uses the native sqlite binaries, but sqlite-net-pcl. This is the steps I followed to install it:
Add the aspnetcore-dev branch to your nuget feeds. Nuget 3: https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
Check "Show preview versions" in Nuget and update (or reinstall) all EntityFrameworkCore packages to "1.2.0 - preview"
(Make sure your x64 is checked in your android projects advanced build options, if the app instantly crashes on deploy. This might be unreleated)
I am trying to run a project on meteor but getting this error in the command line-
this project uses Meteor1.0.2.1, which isn't available on Windows. To
work with is app on all supported platforms, use ,meteor update
--release METEOR#1.1.0.2 to pin this app to the newest Windows-compatible release.
I have tried updating to which I am getting the error message
while checking for meteorhacks:kadira-binary-deps#1.2.1:error: No
compatible binary build found for this package. Contact the package
author and ask them to publish it for your platform.
I tried updating this to which i was brought back to the first error message.
Does anyone know how I can run this meteor package? It is sparrow-finance to be specific.
Regards
Chris
The answer is simply remove the kadira package which you can do by editing the packages file in .meteor.
But, kadira is really useful. So what I'd suggest is to set up meteor environments. Meteor cookbook has a good example of this - https://github.com/awatson1978/meteor-cookbook/blob/master/cookbook/environment-detection.md .
If your environment is anything other than local, use kadira, else don't use it.