question

DonGlover-0631 avatar image
3 Votes"
DonGlover-0631 asked MurrayDave answered

Proguard and shrinking the APK

I am following the steps to prepare for publishing my app found here
https://docs.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://docs.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?

dotnet-xamarinformsdotnet-xamarinessentials
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@DonGlover-0631, I did a test, but I couldn't reproduce this problem.Could you please share your detailed steps and screenshots with me?

0 Votes 0 ·

1 Answer

MurrayDave avatar image
0 Votes"
MurrayDave answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.