Gradle: Run the clean task before anything else to make sure nothing is cached. #2705
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Headache time 🤕⏱️!
As clearly described by @DexerBR in #2704 :
For a still unknown(likely a Gradle bug) reason, the produced
APK
is bigger on non-first builds.After some analysis (unpacked the APK, checked and compared the content), I can say that only the size of the APK itself is different, not the content, as when it gets unzipped, the size of the unzipped content is the same between the first build and subsequent ones.
The files md5 hashes are the same, except for the
assets/private.tar
file (and its content), as I'm not building withSOURCE_DATE_EPOCH
set, which means that compileall uses thetimestamp
as the invalidation mode, making the build non-reproducible.That's where the 💡 toggled on.
What's the size of my
assets/private.tar
?17MB
What's the APK size difference between the first and subsequent builds?
17MB
Ouch! 😓
For some reason, Gradle creates a bigger APK, which is able to contain all the assets and code + 2x
private.tar
(the old one, and the new one), but then only packages into it the newer one.I will try to investigate it on Gradle (and Android Gradle Plugin) codebase, but meanwhile, cleaning the build folder (via
./gradlew clean *****
) avoids any caching and ensures a clean build, every time, and doesn't seem to take any considerable amount of time.EDIT:
Found a discussion on Google Issue Tracker about something similar: https://issuetracker.google.com/issues/172762362