Testing R8 in Xamarin Forms 2019

So I decided to finally use R8 in one of my apps, since the last blog post the idea was to test the code shrinker for D8.

The final size of the Code Dex in the app was impacted by 39%. On the other side the total app size is not that higly impacted. But size matters.

R8 VS None Graph

So It was not as easy as I tought it would be, after publishing for the internal test run on Play Store, the App had a Crash on startup. Here is the log.

Log Of App Crash

Let’s Start Using It

So after looking into more detail of the problem It seems that it was related to which is the one used for the ads in the App. So I had to create a configuration file for R8 in my Android Project.

I must say that there is a complete lack of information on this for Visual Studio and Xamarin so I had to test by myself, someone point out in a blog that the configuration of R8 is based on the ProGuard so I decided to give it a try.

R8 Configuration File Xamarin

So I created this file as you can see in the image but after testing again the app crash on the login screen.

So looking at the Debug it was because R8 was taking part of the V7 and V4 widgets used by the Splash Screen so the configuration file was at the end like this.

-keep class** { *; }
-keep class** { *; }
-keep class { *; }

Now the Build procces was done using App Bundle and no errors on testing.

The console did show some Warnings related to R8 but no big issues. On the Size of the Dex Code this is the result.

App Size using D8/R8 Xamarin Forms

As you can see the Code Dex is greatly impacted by using D8/R8 I just think that doing the R8 configuration is a little bit difficult as there a no tutorial on how to use it, at least for Xamarin Forms.

My App is working but I had to used two hours to figure how to create a configuration file and what was R8 doing for the app the to crash.

I think I will switch to using D8 and R8 by default since I can understand a little bit more of the dinamic R8 is using and now I can configure what to skip.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *