Proguard and shrinking the APK

Don Glover 511 Reputation points
2020-11-24T16:21:20.117+00:00

I am following the steps to prepare for publishing my app found here
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/proguard

I am at the shrink the APK step and it suggests using proguard. I went to this document for instructions:

https://learn.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/proguard

When I compile with the dex compiler setting, I get the following:
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(556,2): error XA1011: Using ProGuard with the D8 DEX compiler is no longer supported. Please set the code shrinker to r8 in the Visual Studio project property pages or edit the project file in a text editor and set the AndroidLinkTool MSBuild property to r8.

==========
Rebuild All: 1 succeeded, 1 failed, 1 skipped ==========

If I set the dex compiler to dx, I get the following:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(560,2): warning XA1023: Using the DX DEX Compiler is deprecated. Please update $(AndroidDexTool) to d8.

My question(s): Is proguard not the way to go these days and the docs are out of date?

re: What is the actual CURRENT guidance for this?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,291 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Dave Murray 1 Reputation point
    2020-12-04T12:44:53.233+00:00

    The answer is in the error message:

    Please set the code shrinker to r8

    When using the d8 dex compiler you need to use the r8 linker. This is the correct method for ensuring smaller apps. Dex & Proguard is an old, less capable method.

    0 comments No comments