I have Android Studio project that needs 20-40 seconds to build after running clean task. It depends on CPU temperature, NTFS filesystem cache state and maybe something else.
BUILD SUCCESSFUL in 23s
38 actionable tasks: 38 executed
Sometimes I'm working on battery with reduced notebook performance and I want to save time and battery energy.
I started searching for solutions to speed up Gradle Build and I found this:
org.gradle.caching=true # added to gradle.build file
After enabling Gradle cache my build is significantly faster:
BUILD SUCCESSFUL in 4s
38 actionable tasks: 14 executed, 24 from cache
During programming/debugging work, the increase in performance will probably not be that significant, but it will probably be noticeable.
Question:
What can go wrong if I'm using it? Why this is not enabled by default?
CodePudding user response:
I've used it always and haven’t run into any issues so far. But,
- if cache files become corrupted it could cause build issues
- you might end up with version compatibility issues when multiple projects share the same cache
- increased disk space usage.
It might not be enabled by default due to these reasons. Enable it and use it for a while to see whether it impacts the build. In that case just clear the cache and things should get back to normal. But I highly recommend using it since it significantly improves the build time cause time is money!