# Cache for Android/Java/Gradle builds

**URL:** <https://travis-ci.community/t/cache-for-android-java-gradle-builds/536>\
**Category:** Feature Requests\
**Tags:** android, caching\
**Created:** [October 28, 2018, 5:00pm UTC](https://travis-ci.community/t/cache-for-android-java-gradle-builds/536 "2018-10-28T17:00:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![noamtamim](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/noamtamim/32/301_2.png) [@noamtamim](https://travis-ci.community/u/noamtamim)\
**Post date:** [October 28, 2018, 5:00pm UTC](https://travis-ci.community/t/cache-for-android-java-gradle-builds/536/1 "2018-10-28T17:00:13Z")

</div>

Similar to what you just added for Node.js ([https://changelog.travis-ci.com/for-node-js-builds-cache-npm-shortcut-is-available-77295](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.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [October 29, 2018, 12:20am UTC](https://travis-ci.community/t/cache-for-android-java-gradle-builds/536/2 "2018-10-29T00:20:08Z")

</div>

What should be cached?

---

<div class="post-metadata">

**Author:** ![noamtamim](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/noamtamim/32/301_2.png) [@noamtamim](https://travis-ci.community/u/noamtamim)\
**Post date:** [November 13, 2018, 10:10am UTC](https://travis-ci.community/t/cache-for-android-java-gradle-builds/536/3 "2018-11-13T10:10:32Z")

</div>

See this thread on SO:

> <https://stackoverflow.com/questions/26723369/cache-gradle-dependencies-travis-ci>

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

> <https://stackoverflow.com/questions/26723369/cache-gradle-dependencies-travis-ci/29647967#29647967>

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

```auto
 - $HOME/.gradle/caches/2.3

```

But in the linked GitHub source file it appears as:

```auto
 - $HOME/.gradle/caches/4.1

```

---

<div class="post-metadata">

**Author:** ![noamtamim](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/noamtamim/32/301_2.png) [@noamtamim](https://travis-ci.community/u/noamtamim)\
**Post date:** [November 13, 2018, 10:24am UTC](https://travis-ci.community/t/cache-for-android-java-gradle-builds/536/4 "2018-11-13T10:24:02Z")

</div>

Your caching guide says we [shouldn’t cache the Android SDKs](https://docs.travis-ci.com/user/caching#things-not-to-cache). But evidence says otherwise. For example:

> **[Cache your Android SDK with Travis – BoD – Medium](https://medium.com/@bod/cache-your-android-sdk-with-travis-c816b9264708)**
>
> Enjoy faster builds by not doing unnecessary downloads.

  
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.
