Skip to content Skip to sidebar Skip to footer

Enabling Proguard - Xamarin.android

In the release mode, when i enable only multi dex, my app size is 33.30MB which is quite large. After series of research, i realized PROGUARD shrinks the apk size. Enabling progua

Solution 1:

Proguard is telling you that you need to fix your warnings before it will allow it to build.

   java.io.IOException: Please correct the above warnings first.
        at proguard.Initializer.execute(Unknown Source)
        at proguard.ProGuard.initialize(Unknown Source)
        at proguard.ProGuard.execute(Unknown Source)
        at proguard.ProGuard.main(Unknown Source)

You can either go one-by-one to fix all of these errors(By using -keep), or you can ignore the warnings. There are two ways to go about this:

  1. Using -ignorewarnings

Specifies to print any warnings about unresolved references and other important problems, but to continue processing in any case. Ignoring warnings can be dangerous. For instance, if the unresolved classes or class members are indeed required for processing, the processed code will not function properly. Only use this option if you know what you're doing!

https://www.guardsquare.com/en/proguard/manual/usage#ignorewarnings

  1. Using -dontwarn [class_filter]

Specifies not to warn about unresolved references and other important problems at all. The optional filter is a regular expression; ProGuard doesn't print warnings about classes with matching names. Ignoring warnings can be dangerous. For instance, if the unresolved classes or class members are indeed required for processing, the processed code will not function properly. Only use this option if you know what you're doing!

https://www.guardsquare.com/en/proguard/manual/usage#dontwarn

You can find out how to create a custom proguard configuration via the documentation I wrote:

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/proguard/#Customizing_ProGuard

Why do you get those warnings you may ask? It's most likely due to the Linker stripping these items before Proguard is run. See my notes on this here:

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/proguard/#Linker_Step

Post a Comment for "Enabling Proguard - Xamarin.android"