While setting up a SQLite DB in a Xamarin.Forms app for the first time in a while, I stumbled upon an error that made me pull my hair.
I was following this tutorial from Microsoft: Using SQLite.NET with Android
After installing the required SQLite .NET-PCL nuget package, I went forth with setting up the DB connection (step 2 in the tutorial).
While trying to do this, I noticed that the SQLiteConnection class didn’t have an overload that matched the number of arguments I was trying to pass. This made me scratch my head, since according to the tutorial and my previous experience there should be one. I recieved the following error message:
After taking the following measures:
- Testing other namespaces which include SQLite
- Doublechecking that I had the most recent version of the SQLite.NET nuget
- Cleaning/building the solution
- Restarting Visual Studio
- Restarting my computer
- Reading the source code for SQLite.NET to see what constructors there were available
There was nothing much but hairpulling and screaming left. Then I decided to double check the nugets one last time. That’s when I saw it:
I had installed “SQLite.Net-PCL” nuget when I should have installed the lowercase “sqlite-net-pcl”. To further add to the confusion from the two nugets having the same name, they also have the same author (Frank Krueger).
(Clarification: in the screenshot above I have installed the correct nuget)
After installing the lowercase “sqlite-net-pcl” nuget it worked like a charm.
Conclusion: if you’re experiencing the same conundrum while setting up a SQLite DB in Xamarin.Forms, double check that you’re not a fool for the old SQLite nuget shuffle!