apk size is huge because of Mono.Android.dll

Hi all, I have this strange problem from last releases my apk file is huge in size, and checking what is inside I found that Mono.Android.dll is 24.2 MB, but in past releases it was only 1.4 MB.
Minimum android version is 15 and target android version is 23.

what happens in your opinion ?
any idea ?

thanks a lot for help

Posts

  • YkshLeoYkshLeo USMember ✭✭✭✭
    edited January 2016

    I think you can make use of Linker to reduce size of .apk file.

    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. But instead of operating over objects, linking operates over your code.


    Refer :

  • Luca.7923Luca.7923 USMember ✭✭

    thanks @YkshLeo for your great suggestion, but I am quite astonished that my Mono.android.dll is becoming so big without a reason

  • YkshLeoYkshLeo USMember ✭✭✭✭

    @Luca.7923,

    https://developer.xamarin.com/guides/android/advanced_topics/application_package_sizes/

    In this article it is clearly shows all about Application Package Sizes (including Mono.android.dll)


    For example, take the default "Hello World” template, the contents of a complete package build would look like this :

    After running the linker on the Hello World application, our package now looks like this :

  • YkshLeoYkshLeo USMember ✭✭✭✭

    @Luca.7923,

    Do you have a large sized Mono.android.dll even after using Linker ?

  • Luca.7923Luca.7923 USMember ✭✭

    Hi @YkshLeo thanks for your suggestion, the the linker is the solution. Checking log from Git I see that the .csproj file has been changed, adding this line

    <AndroidLinkMode>None</AndroidLinkMode>
    

    so the linker was disabled,
    now with link sdk assemblies only all works and the package size is fine (17 MB, as before)

    Thanks again

  • MHLDMHLD BRBeta ✭✭

    Hi @YkshLeo and @Luca.7923 !

    Even with Linking enabled for Sdk Assemblies, Mono.Android.dll has 7.427KB!
    I'm using FreshMvvm.
    Do you think this could be the problem?

  • batmacibatmaci DEMember ✭✭✭✭✭

    @MHLD have you ever figured that out? I am using also Freshmvvm if it is something related. even though when I check, it has already its own dll.

  • Amit02Amit02 INMember ✭✭

    Hi all, i am facing problem with apk size. My apk file is huge in size. I followed the above steps but still i am facing same issue. I am unable to get what is going wrong. Please help me.

  • AlbertKAlbertK MYMember ✭✭✭✭

    Set the linking to "Sdk and User Assemblies"

  • Amit02Amit02 INMember ✭✭
    edited June 2017

    @AlbertK , I tried this option. It reduced the apk size but app getting crashed . I am getting message "Unfortunately, App Name has stopped."

  • AlbertKAlbertK MYMember ✭✭✭✭

    You have to find out which assembly this is causing the crash and exclude it from linking.

    Can you post the error log /crash log here?

  • Amit02Amit02 INMember ✭✭
    edited June 2017

    I am looking for Crash log error but unable to get what is going wrong . I am sending you output log

  • AlbertKAlbertK MYMember ✭✭✭✭
    edited June 2017

    Do the following

    VS 2015 Menu -> Tools -> Android -> Android ADB command prompt. Type in the following in the command prompt
    1) adb shell
    2) logcat | grep BabyFeedMonitor

    (Please do not type in the numbers)

    3) Run your app and get the log when to app crash. Post it here.

  • AlbertKAlbertK MYMember ✭✭✭✭

    I saw that you have enabled proguard. Please disable it for now. That should fix the problem. you need to exclude the assembly that is removed by the proguard and that will need some detective work using the adb shell.

    if you are not familiar with adb shell then don't do the proguard optimization now as it will only reduces 1 to 2MB. The "Sdk and User Assemblies" option will give you much mileage.

  • Amit02Amit02 INMember ✭✭
  • Amit02Amit02 INMember ✭✭

    Now i have disabled the proguard .But i am getting same crashing error

  • AlbertKAlbertK MYMember ✭✭✭✭

    1) Clear the Skip Linking Assemblies and put in this

    Xamarin.Android.Support.v4

    2) Build and Deploy

  • Amit02Amit02 INMember ✭✭

    after this, apk size has been reduced but it is getting crashed.

  • AlbertKAlbertK MYMember ✭✭✭✭

    Crash Log is missing.

  • AlbertKAlbertK MYMember ✭✭✭✭

    Remove the Xamarin.Android.Support.v4 and replace with

    Xamarin.Android.Support.v7.AppCompat

  • Amit02Amit02 INMember ✭✭
    edited June 2017

    Same error

  • AlbertKAlbertK MYMember ✭✭✭✭

    @Amit02 if you set the Linking to "SDK Assemblies Only" does it crash? If not then it is one or more of the other assemblies that is the cause.

    Add one assemblies to skip at time until you find the correct one, then remove the others one at a time, test. Eg

    Xamarin.Android.Support.v7.AppCompat;Xamarin.Android.Support.v7.RecyclerView

Sign In or Register to comment.