From 78d662ee7d82ecadd45dee0b4eba548c4d2f3288 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 23 Apr 2019 14:21:21 -0500 Subject: [PATCH] Remove Xamarin.Android.Support.v7.MediaRouter (#5941) Context: https://github.com/xamarin/xamarin-android/issues/2982 The Blank Xamarin.Forms app template in VS 2019 takes longer to build than in VS 2017. A little research is showing that this is due to use of the 28.x support libraries... For example, the build includes ~20 *more* jar files in the template from 2019 than 2017. The `_CompileDex` step alone goes from ~15.2s to ~18.2s. This lead me down the road of investigating if we can remove any support libraries by default in Xamarin.Forms apps. I am also seeing if there is more we can do in Xamarin.Android for this problem, in general. It looks like we can remove: * Xamarin.Android.Support.v7.MediaRouter * Xamarin.Android.Support.Media.Compat Neither of these appear to be used, but have been listed as dependencies of Xamarin.Forms for a long time. ~~ Results ~~ I made these changes, then did a `Debug` build of `Xamarin.Forms.ControlGallery.Android.csproj` for comparison. Comparing dex file sizes (in bytes): Before: 3428092 classes.dex 3265616 classes2.dex 6693708 total After: 4938000 classes.dex 1098772 classes2.dex 6036772 total This looks like it could potentially save ~600KB of compiled dex code on every Xamarin.Forms app. Comparing methods: Before: classes.dex 11,492 methods classes2.dex 19,451 methods total 30,943 methods After: classes.dex 22,171 methods classes2.dex 7,635 methods total 29,806 methods ~1,137 methods removed, which should help with the dex limit. Comparing APK sizes (in bytes): Before: 26442597 AndroidControlGallery.AndroidControlGallery-Signed.apk After: 25741701 AndroidControlGallery.AndroidControlGallery-Signed.apk ~700KB smaller APK, due to less .NET assemblies & dex code. Comparing build time (this was using dx): Before: 19785 ms CompileToDalvik 1 calls After: 18532 ms CompileToDalvik 1 calls Looks like it saved over a second of build time for this project. Seems like an "easy win", let's do this! --- .nuspec/Xamarin.Forms.Maps.nuspec | 1 - .nuspec/Xamarin.Forms.nuspec | 1 - PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj | 2 -- .../Xamarin.Forms.ControlGallery.Android.csproj | 2 -- Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj | 1 - Xamarin.Forms.Sandbox.Android/Xamarin.Forms.Sandbox.Android.csproj | 1 - 6 files changed, 8 deletions(-) diff --git a/.nuspec/Xamarin.Forms.Maps.nuspec b/.nuspec/Xamarin.Forms.Maps.nuspec index e11702d..1a4cb10 100644 --- a/.nuspec/Xamarin.Forms.Maps.nuspec +++ b/.nuspec/Xamarin.Forms.Maps.nuspec @@ -19,7 +19,6 @@ - diff --git a/.nuspec/Xamarin.Forms.nuspec b/.nuspec/Xamarin.Forms.nuspec index 8f9d9fa..9cc0a80 100644 --- a/.nuspec/Xamarin.Forms.nuspec +++ b/.nuspec/Xamarin.Forms.nuspec @@ -18,7 +18,6 @@ - diff --git a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj index 88aeb85..711845a 100644 --- a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj +++ b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj @@ -282,12 +282,10 @@ - - diff --git a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj index e3a2509..c0cfa0d 100644 --- a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj +++ b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj @@ -351,12 +351,10 @@ - - diff --git a/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj b/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj index 7e2d8a7..7008c84 100644 --- a/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj +++ b/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj @@ -84,7 +84,6 @@ - diff --git a/Xamarin.Forms.Sandbox.Android/Xamarin.Forms.Sandbox.Android.csproj b/Xamarin.Forms.Sandbox.Android/Xamarin.Forms.Sandbox.Android.csproj index bcae908..55d4496 100644 --- a/Xamarin.Forms.Sandbox.Android/Xamarin.Forms.Sandbox.Android.csproj +++ b/Xamarin.Forms.Sandbox.Android/Xamarin.Forms.Sandbox.Android.csproj @@ -57,7 +57,6 @@ - -- 2.7.4