├── Images ├── ProjectSettings.png └── DiagnosticBuildOutput.png ├── .github └── ISSUE_TEMPLATE │ ├── ---app-size.md │ ├── ---startup-performance.md │ ├── ---build-performance.md │ └── ---build-performance--startup-performance--and-app-size.md ├── LICENSE ├── README.md └── .gitignore /Images/ProjectSettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonDouglas/AndroidPerformanceAndAppSizeChallenge/HEAD/Images/ProjectSettings.png -------------------------------------------------------------------------------- /Images/DiagnosticBuildOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonDouglas/AndroidPerformanceAndAppSizeChallenge/HEAD/Images/DiagnosticBuildOutput.png -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---app-size.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F600 App Size" 3 | about: Provide your app's size difference for swag! 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | - Follow the directions found here: https://github.com/JonDouglas/AndroidPerformanceAndAppSizeChallenge#application-size 11 | 12 | ## Application Size (Download Size) 13 | 14 | - Before Application Size Changes: 15 | 16 | ``` 17 | App download size: 0MB 18 | ``` 19 | 20 | - After Application Size Changes: 21 | 22 | ``` 23 | App download size: 0MB 24 | ``` 25 | 26 | ## Any comments / feedback for how we can improve this experience? 27 | 28 | ## Version Information (`Help -> About Visual Studio -> Copy Information`) 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---startup-performance.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F601 Startup Performance" 3 | about: Provide your app's startup performance for swag! 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | - Follow the directions found here: https://github.com/JonDouglas/AndroidPerformanceAndAppSizeChallenge 11 | 12 | ## Startup Performance (Activity Displayed) 13 | 14 | - Before Startup Tracing: 15 | 16 | ``` 17 | ActivityManager: Displayed com.companyname.yourapp/MainActivity: +0s0ms 18 | ``` 19 | 20 | - After Startup Tracing: 21 | 22 | ``` 23 | ActivityManager: Displayed com.companyname.yourapp/MainActivity: +0s0ms 24 | ``` 25 | 26 | ## Any comments / feedback for how we can improve this experience? 27 | 28 | ## Version Information (`Help -> About Visual Studio -> Copy Information`) 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jon Douglas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---build-performance.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F603 Build Performance" 3 | about: Provide your app's build performance for swag! 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | - Follow the directions found here: https://github.com/JonDouglas/AndroidPerformanceAndAppSizeChallenge#build-times 11 | 12 | ## Build Performance (No bin/obj) 13 | 14 | - Before Cold Build Times Changes: 15 | 16 | ``` 17 | Time Elapsed 00:00:00.00 18 | ``` 19 | 20 | - After Cold Build Times Changes: 21 | 22 | ``` 23 | Time Elapsed 00:00:00.00 24 | ``` 25 | 26 | ## Build Performance (Incremental change) 27 | 28 | - Before Incremental Build Times Changes: 29 | 30 | ``` 31 | Time Elapsed 00:00:00.00 32 | ``` 33 | 34 | - After Incremental Build Times Changes: 35 | 36 | ``` 37 | Time Elapsed 00:00:00.00 38 | ``` 39 | 40 | ## Bonus 41 | 42 | - Include a [Diagnostic MSBuild Log File](https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/troubleshooting#diagnostic-msbuild-output) or [MSBuild BinLog File](http://msbuildlog.com/) 43 | 44 | ## Any comments / feedback for how we can improve this experience? 45 | 46 | ## Version Information (`Help -> About Visual Studio -> Copy Information`) 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---build-performance--startup-performance--and-app-size.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F642 Build Performance, Startup Performance, and App Size" 3 | about: Provide your app's build performance, startup performance, and app size for 4 | swag! 5 | title: '' 6 | labels: '' 7 | assignees: '' 8 | 9 | --- 10 | 11 | - Follow the directions found here: https://github.com/JonDouglas/AndroidPerformanceAndAppSizeChallenge 12 | 13 | ## Build Performance (No bin/obj) 14 | 15 | - Before Cold Build Times Changes: 16 | 17 | ``` 18 | Time Elapsed 00:00:00.00 19 | ``` 20 | 21 | - After Cold Build Times Changes: 22 | 23 | ``` 24 | Time Elapsed 00:00:00.00 25 | ``` 26 | 27 | ## Build Performance (Incremental change) 28 | 29 | - Before Incremental Build Times Changes: 30 | 31 | ``` 32 | Time Elapsed 00:00:00.00 33 | ``` 34 | 35 | - After Incremental Build Times Changes: 36 | 37 | ``` 38 | Time Elapsed 00:00:00.00 39 | ``` 40 | 41 | ## Startup Performance (Activity Displayed) 42 | 43 | - Before Startup Tracing: 44 | 45 | ``` 46 | ActivityManager: Displayed com.companyname.yourapp/MainActivity: +0s0ms 47 | ``` 48 | 49 | - After Startup Tracing: 50 | 51 | ``` 52 | ActivityManager: Displayed com.companyname.yourapp/MainActivity: +0s0ms 53 | ``` 54 | 55 | ## Application Size (Download Size) 56 | 57 | - Before Application Size Changes: 58 | 59 | ``` 60 | App download size: 0MB 61 | ``` 62 | 63 | - After Application Size Changes: 64 | 65 | ``` 66 | App download size: 0MB 67 | ``` 68 | 69 | ## Bonus 70 | 71 | - Include a [Diagnostic MSBuild Log File](https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/troubleshooting#diagnostic-msbuild-output) or [MSBuild BinLog File](http://msbuildlog.com/) 72 | 73 | ## Any comments / feedback for how we can improve this experience? 74 | 75 | ## Version Information (`Help -> About Visual Studio -> Copy Information`) 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Performance and App Size Challenge 2 | Use the new Xamarin.Android features and open up an issue with your results 3 | 4 | # Before you start 5 | 6 | 1. Ensure you're on at least a 16.2/8.2 version of [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac) respectfully. 7 | 8 | 2. Enable [Diagnostic MSBuild Output](https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/troubleshooting#diagnostic-msbuild-output) or use [MSBuild BinLog](http://msbuildlog.com/). 9 | 10 | ![](Images/DiagnosticBuildOutput.png) 11 | 12 | 3. Open up the Android Device Log by going to `Tools > Android > Device Log` 13 | 14 | 4. Familiarize yourself with the Android Project Options Screen 15 | 16 | ![](Images/ProjectSettings.png) 17 | 18 | **You're ready to begin the challenge! Pick your challenge below, or do all three!** 19 | 20 | ## Build Times 21 | - [Enable aapt2](https://devblogs.microsoft.com/xamarin/optimize-xamarin-android-builds/). 22 | - [Enable D8](https://devblogs.microsoft.com/xamarin/androids-d8-dexer-and-r8-shrinker/). 23 | - [Use Portable PDB](https://devblogs.microsoft.com/xamarin/optimize-xamarin-android-builds/). 24 | - [Enable Reference Assemblies](https://devblogs.microsoft.com/xamarin/optimize-xamarin-android-builds/). 25 | 26 | Within a .csproj, add the following properties to your current configuration: 27 | 28 | ``` 29 | 30 | true 31 | d8 32 | portable 33 | True 34 | 35 | ``` 36 | 37 | Build Times should be measured with a `Debug` configuration. To measure the performance, enable [Diagnostic MSBuild Output](https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/troubleshooting#diagnostic-msbuild-output) or use [MSBuild BinLog](http://msbuildlog.com/) to provide the time elapsed. 38 | 39 | **Bonus:** If you can include a full MSBuild Output or MSBuild BinLog, this will help us understand where time is allocated to each target and task while building your app! This will help us understand bottlenecks and where to improve in the future. 40 | 41 | **Before Cold Build Times Changes:** 42 | ``` 43 | Time Elapsed 00:00:15.77 44 | ``` 45 | 46 | **After Cold Build Times Changes:** 47 | ``` 48 | Time Elapsed 00:00:14.85 49 | ``` 50 | 51 | **Note:** To do a **cold build**, `Clean` your project prior to building. 52 | 53 | **Before Incremental Build Times Changes:** 54 | ``` 55 | Time Elapsed 00:00:02.67 56 | ``` 57 | 58 | **After Incremental Build Times Changes:** 59 | ``` 60 | Time Elapsed 00:00:02.43 61 | ``` 62 | 63 | **Note:** To do an **incremental build**, change a single piece of code (XAML / C# / etc) and deploy your project. 64 | 65 | ## Startup Times 66 | 67 | - [Enable Startup Tracing](https://devblogs.microsoft.com/xamarin/faster-startup-times-with-startup-tracing-on-android/). 68 | 69 | Within a .csproj, add the following property to your release configuration: 70 | 71 | ``` 72 | 73 | true 74 | 75 | ``` 76 | 77 | Startup Times should be measured with a `Release` configuration. To measure the performance, with the Android Device Log, add a filter to search for `ActivityManager: Displayed` to which you will be provided a timing of your application such as: 78 | 79 | **Before Startup Tracing:** 80 | ``` 81 | 2019-08-19 09:35:43.374 1870-1892/? I/ActivityManager: Displayed com.companyname.startuptiming/md5984e4549386b302a2fd47914e0849f36.MainActivity: +2s995ms 82 | ``` 83 | 84 | **After Startup Tracing:** 85 | ``` 86 | 2019-08-19 09:37:40.504 1870-1892/? I/ActivityManager: Displayed com.companyname.startuptiming/md5984e4549386b302a2fd47914e0849f36.MainActivity: +1s760ms 87 | ``` 88 | 89 | **Note:** The checkbox for Startup Tracing is included in Visual Studio 2019 16.3 Preview 2 and Visual Studio 2019 8.3 Preview 2. 90 | 91 | ## Application Size 92 | - [Enable d8](https://devblogs.microsoft.com/xamarin/androids-d8-dexer-and-r8-shrinker/). 93 | - [Enable ProGuard](https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/proguard) or [r8](https://devblogs.microsoft.com/xamarin/androids-d8-dexer-and-r8-shrinker/). 94 | - [Create an Android App Bundle](https://github.com/xamarin/xamarin-android/blob/master/Documentation/guides/app-bundles.md). 95 | 96 | Within a .csproj, add the following properties to your release configuration: 97 | ``` 98 | 99 | aab 100 | d8 101 | r8 102 | 103 | ``` 104 | 105 | Now create an Android App Bundle via the command line: 106 | 107 | ``` 108 | msbuild -restore AndroidApp.csproj 109 | -t:SignAndroidPackage 110 | -p:Configuration=Release 111 | -p:AndroidKeyStore=True 112 | -p:AndroidSigningKeyStore=com.contoso.keystore 113 | -p:AndroidSigningStorePass=password 114 | -p:AndroidSigningKeyAlias=keyAlias 115 | -p:AndroidSigningKeyPass=password 116 | ``` 117 | 118 | Application size should be measured with a `Release` configuration and signed package. To measure the perceived app download size, you can use [Android Studio's APK Analyzer](https://developer.android.com/studio/build/apk-analyzer) or with the [following command](https://developer.android.com/studio/command-line/apkanalyzer) in your `Android SDK/tools/bin` location: 119 | 120 | ``` 121 | apkanalyzer -h apk download-size myapk.apk 122 | ``` 123 | 124 | or 125 | 126 | ``` 127 | apkanalyzer -h apk download-size myaab.aab 128 | ``` 129 | 130 | **Note:** [apkanalyzer may not work on Windows](https://issuetracker.google.com/issues/75981301). 131 | 132 | **Before Application Size Changes:** 133 | ``` 134 | App download size: 23.6MB 135 | ``` 136 | 137 | **After Application Size Changes:** 138 | ``` 139 | App download size: 4.82MB 140 | ``` 141 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | --------------------------------------------------------------------------------