Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Forms : Apk size is too large

I create a new project in Xamarin.Forms and just debug it. I do nothing and just create a Apk file and apk size is 14.2 MB. I found some tutorial regarding and changes Linker behaviour to Link all assemblies. It reduces Apk size to 1 or 2 MB. In fact I am expecting size of such Apk should be in some kbs. What I am missing here?

like image 999
Dipak Avatar asked Aug 30 '16 12:08

Dipak


1 Answers

You can read all about that here in the documentation.

Your main problem here is that a lot of .NET stuff is being included as it is not available on your Android device by default.

APK size without Linker (Image by Xamarin)

15.8 MB is a larger download size than we’d like. The problem is the BCL libraries, as they include mscorlib, System, and Mono.Android, which provide a lot of the necessary components to run your application. However, they also provide functionality that you may not be using in your application, so it may be preferable to exclude these components.

But they may not be necessary! This is where the Linker comes in.

APK size when using the Linker (Image by Xamarin)

When we build an application for distribution, we execute a process, known as Linking, that examines the application and removes any code that is not directly used. This process is similar to the functionality that Garbage Collection provides for heap-allocated memory.

You can access the linker settings from your Xamarin.Droid project properties. Look around at the different settings there and play with them to see what it has for effect.

like image 200
Gerald Versluis Avatar answered Nov 07 '22 10:11

Gerald Versluis