I am here for a clear understanding of a subject and maybe for a solution from you. I've been working on an Android project pretty big, an application which generated APK was around 40Mb for debug flavour and 30-32Mb on the release one (proguard, shrink resources, etc)
Now, I wanted to update the project and get rid of findViewById() and ButterKnife library. So far so good.
My concern is that now, the generated APKs have increase with 10 Mb each flavour. 52Mb for debug and 40Mb for release just by this viewBinding addition.
I know that, according to other StackOverflow posts it can vary based on project size and most importantly based on how many XML layouts it contains. I can assure you the project does not have over 1000 layouts.
Extract from other blogs mention that an average project with 1000 layouts and 10 child views in each layout would result in 200Kb increase in APK size, which made me thing there could be something wrong.
The impact of APK size is less predictable because the size of each generated class will depend upon the complexity of the layout – specifically how many Views exist with an id attribute. For the layout we looked at earlier the size of the class within the release APK is 552 bytes. For a more complex layout with 10 views of different types, this increased to 989 bytes. While neither of these are huge, the impact will depend on how many layouts you have within your project. For a project where I added an additional 1000 layouts each containing 10 child Views the release APK the APK increased from 3.9 MB to 4.1MB without proguarding. I think that few projects will contain 1000 XML layouts, but many will contain layouts rather more complex than having 10 child Views. However, a 200 KB increase in APK size isn’t a big deal, in my opinion.
What I tried to do:
- clean everything that was not needed in the project (resources, unused classes, added
viewBindingIgnore="true"on the layouts that didn't need to have a class generated for it, etc). Without a visible result on the APK size. Anything else that I could've missed or what could I do further ?
Thanks in advance.