

Android App BundlesĪpp Bundles are a new publishing format for Android applications.

r8 is the companion to d8, giving you the same features as ProGuard. Using d8 by itself will improve build times and make your APK a bit smaller. Keep in mind that the r8 Code Shrinker (just like ProGuard) is meant to be enabled for Release builds. d8 and r8ĭ8 and r8, are an easy improvement to enable in your app if you have not already. If you author your UIs with Android XML layouts, then this setting is a must:Īapt2 will soon be the default in future Xamarin.Android releases, so give it a try today. aapt2 is a new implementation that vastly improves performance for incremental builds. Android Asset Packaging Tool (aapt)ĪAPT is responsible for processing Android resource files and creating the “base” of an APK. Read more on the subject in Faster Startup Times with Startup Tracing on Android. It is a “best of both worlds” trade off that only slightly increases APK sizes. However, a new feature in Visual Studio 2019 16.2, Enable Startup Tracing, allows you to enable AOT for only the startup path of your application. This produces Android applications with a faster startup and better overall performance, at the cost of a larger APK. NET assemblies into native code “ahead of time”. ProGuard rules allow developers to be specific about which Java classes must be kept. This shrinks compiled Java code in your application, which can also strip too much code in some cases.


Likewise, your application should enable a Java Code Shrinker, such as ProGuard. Check out our documentation on linking for details. Many Xamarin.Android applications can just toggle this setting however, if you take advantage of System.Reflection it is possible the linker can remove types your application uses. Managed DLLs have to be left uncompressed in your APK, so assemblies will directly contribute to the overall file size. NET assemblies is the first step to get a smaller APK. Release builds have two goals that are sometimes at odds with each other: They will slow down your Debug builds with no real benefit. Using AOT, Linking, or a Code Shrinker for Debug configurations is not that helpful. The following settings should likewise be disabled for Debug builds: See my recent blog post on how fewer projects will need Multi-Dex when using Visual Studio 2019 16.2 or higher. Xamarin.Android applications under the dex limit should not need this setting. NET assemblies to enable a much better experience.Įnable Multi-Dex should be unchecked: unless your app fails to build without it. Without Fast Deployment, Xamarin.Android has to build an APK every time there’s change in your project, regardless of size or scope.
