Cache for Android/Java/Gradle builds

Similar to what you just added for Node.js (https://changelog.travis-ci.com/for-node-js-builds-cache-npm-shortcut-is-available-77295), please also add “shortcut” for caching in Android/Java/Gradle builds.

What should be cached?

See this thread on SO:

It seems that the best solution is (not the accepted answer but a newer one) this:

One issue here: one of the paths to cache changes with every gradle version. In the post it’s quoted as:

 - $HOME/.gradle/caches/2.3

But in the linked GitHub source file it appears as:

 - $HOME/.gradle/caches/4.1

Your caching guide says we shouldn’t cache the Android SDKs. But evidence says otherwise. For example:


This says there was major improvement in build times. But they took a different approach – they downloaded the SDKs without using your built-in Android support.