fix apk total size calculation#18
Conversation
| val classDownloadSize = flatMap { it.dexes }.flatMap { it.classes }.sumOf { it.downloadSize } | ||
| val total = | ||
| resourceDownloadSize + nativeLibDownloadSize + assetDownloadSize + otherDownloadSize + classDownloadSize | ||
| resourceDownloadSize + nativeLibDownloadSize + assetDownloadSize + otherDownloadSize + dexDownloadFile |
There was a problem hiding this comment.
Hi @0xera, thank a lot for reporting and fixing the issues.
By right, the classDownloadSize should ~equal to the dexDownloadFile. A small different might be because this calculation:
Was your project's result largely the difference between Android Studio vs App-sizer report?
There was a problem hiding this comment.
Hi. As the size of the application increases, I get more and more different results.
(Before and after fix)
Download size:
- App Sizer sample:
- My app (APK mode):
| apk | 13.765 MB | 13.778 MB

- Another my app (APK mode):
| apk | 108.818 MB | 108.865 MB

Raw Size:
As you can see, the dexes size calculation is more correct for the size of the downloadable apk (especially for large apk files) and corrects the calculation of the raw size.
There was a problem hiding this comment.
Let me share a bit of context. As I shared in this document https://grab.github.io/app-sizer/limitation/#class-download-size-calculation
class's download size = class raw size * (dex download size / all classes' raw size)
-> Sum (classes download size ) = (sum(class raw size) * dex download size) / all classes' raw size = dex download size
But there is some minor difference due to the rounded number & floating point number on the calculation.
Anyway, if this helps to have a closer number to the Android Studio report. Let merge
Thanks for contributing


I have found that the APK's total size is incorrect and does not match what Android Studio is showing.