- 
                Notifications
    
You must be signed in to change notification settings  - Fork 561
 
Description
I was reviewing build performance, and the time we spend running aapt/aapt2.
I noticed some command-line arguments of aapt2 that look like they could be useful:
https://developer.android.com/studio/command-line/aapt2
aapt2 compile --no-crunch
Disables PNG processing.
Use this option if you have already processed the PNG files, or if
you are creating debug builds that do not require file size reduction.
Enabling this option results in a faster execution, but increases the
output file size.
My thought was not to implement what we have for $(AndroidExplicitCrunch) + aapt(1), but to pass this for debug builds.
So I tried comparing a build with passing /p:AndroidAapt2CompileExtraArgs=--no-crunch:
Before:
5675 ms  Aapt2Compile                               2 calls
After:
4161 ms  Aapt2Compile                               2 calls
Logs: HelloForms.zip
This was a "Hello World" Xamarin.Forms app.
If we see benefits with this app, I imagine we'd see even better with apps with lots of PNGs.
Implementation
Add a new property $(AndroidAapt2NoCrunch) that defaults to true for debug builds and false for release builds. If it is not blank, we will use what developers have set.
We can use $(AndroidIncludeDebugSymbols) to decide if it is a debug build or not, as we already do for d8: https://github.com/xamarin/xamarin-android/blob/8e2c93938b74506f204ea35e6a144342b8254fa6/src/Xamarin.Android.Build.Tasks/Xamarin.Android.D8.targets#L116
aapt2 compile --legacy
Treats errors that are permissible when using earlier versions of AAPT
as warnings.
This flag should be used for unexpected compile time errors. To resolve
known behavior changes that you might get while using AAPT2.
Implementation
We don't need to use this yet, but when we phase out aapt(1) support.
If we removed all <Aapt/> calls, we should keep the $(AndroidUseAapt2) property that defaults to true. If set to false, it would pass --legacy to <Aapt2Compile/>.