2

I'm having a go at creating my first Android app using Xamarin. I'll be needing a database, and the Xamarin docs recommend the "SQLite-net-pcl" NuGet package (here). When I go to install this package it lists approx 50 dependencies that it wants to install! How much is this going to increase the size of my app by?

Is this normal with Xamarin development? Coming from a WPF background I admit I haven't got my head around all this .Net core/standard stuff yet.

And why do the docs recommend this package over the built-in 'Android.Database.Sqlite' namespace? Does the ease of use (of the SQLite.net package) outweigh the increase in app size?

5
  • 2
    You can ignore most of those dependent packages, they will not bloat your final app, only the assemblies added that have become assembly references (via package), i.e. SQLite-net and SQLitePCLraw**** Can you use Android.Database.Sqlite instead? Certainly can and thus you will avoid adding a SQLite native shared library (.so) to your app bundle but will be forced in using the possibly older SQLite.so provided by the OS and have to use a Java-style API to access SQLite which is foreign to a lot of C# devs. Commented Jan 24, 2017 at 23:32
  • 1
    Whatever you do not mix the two ways of access as you would be accessing your SQLite db via two different native shared libraries and thus data/file corruption is an option. Android Nougat/7.0 built apps do not allow access to the native SQLite.so library by anything other than the Java Android.Database.Sqlite classes. Also remember that access via the Java Android.Database.Sqlite classes will result in ACW generated classes and a slight overhead due to the peer objects created, the two VMs involved, two different GCs on those objects, etc... Commented Jan 24, 2017 at 23:41
  • @SushiHangover I think I was shocked to see so many package dependencies listed, and was worried that my app's size would balloon as a result - the dependencies seem to represent a substantial portion of .Net! I guess this sort of thing is "normal" on the Xamarin platform? Commented Jan 25, 2017 at 9:44
  • @SushiHangover I'm not sure what you meant by the first sentence in your first comment though. What determines which of those 50+ assemblies get pulled into my app? My (probably naive) assumption was that the SQLite-net-pcl package does need all those assemblies, otherwise they wouldn't be listed as dependencies in the first place. Commented Jan 25, 2017 at 9:46
  • Look at the actual assembly references in your .csproj, you will see only refs to SQLite-net and SQLitePCLraw**** You can remove those "extra" refs if you do not want to see them in your package tree, but they will be re-added, the joys of new netstandard world. The actual Xamarin.iOS and Xamarin.Anrdoid framework assemblies will be used. Commented Jan 25, 2017 at 23:16

1 Answer 1

2

How much is this going to increase the size of my app by?

Not much, Xamarin links out (removes) the unused code when you build your app in release mode. For example if you're not using any methods from System.IO, the assembly will not be included in the final build

Does the ease of use (of the SQLite.net package) outweigh the increase in app size?

Part of it is ease of use and the real advantage is you can reuse the code on iOS or any other platforms. Using Android.Database.Sqlite doesn't help you much if you're planning porting your app to other platforms

What determines which of those 50+ assemblies get pulled into my app?

Dependency on the netstanderd is what pulling those 50+ assemblies, otherwise Sqlite-net-pcl just need SQLitePCLRaw.* assemblies

There is nice series explaining netstanderd from one of the .Net engineers on youtube here - https://www.youtube.com/playlist?list=PLRAdsfhKI4OWx321A_pr-7HhRNk7wOLLY Hope it will answer your questions regarading netstanderd

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.