there seems to be incorrect info posted here. some people report on how to clear the Android builder cache (with task
cleanBuildCache) but do not seem to realize that said cache is independent of Gradle’s build cache, AFAIK.
my understanding is that Android’s cache predates (and inspired) Gradle’s, but i could be wrong. whether the Android builder will be/was updated to use Gradle’s cache and retire its own, i do not know.
EDIT: the Android builder cache is obsolete and has been eliminated. the Android Gradle plugin now uses Gradle’s build cache instead. to control this cache you must now interact with Gradle’s generic cache infrastructure.
TIP: search for Gradle’s cache help online without mentioning the keyword ‘android’ to get help for the currently relevant cache.
EDIT 2: due to tir38’s question in a comment below, i am testing using an Android Gradle plugin v3.4.2 project. the gradle cache is enabled by
gradle.properties. i do a couple of
clean build and the second time most tasks show
FROM-CACHE as their status, showing that the cache is working.
surprisingly, i have a
cleanBuildCache gradle task and a
<user-home>/.android/build-cache/3.4.2/ directory, both hinting the existence of an Android builder cache.
cleanBuildCache and the
3.4.2/ directory is gone. next i do another
- nothing changed: most tasks show
FROM-CACHEas their status and the build completed at cache-enabled speeds.
3.4.2/directory is recreated.
3.4.2/directory is empty (save for 2 hidden, zero length marker files).
- caching of all normal Android builder tasks is handled by Gradle.
cleanBuildCachedoes not clear or affect the build cache in any way.
- there is still an Android builder cache there. this could be vestigial code that the Android build team forgot to remove, or it could actually cache something strange that for whatever reason has not or cannot be ported to using the Gradle cache. (the ‘cannot’ option being highly improvable, IMHO.)
next, i disable the Gradle cache by removing
gradle.properties and i try a couple of
- the builds are slow.
- all tasks show their status as being executed and not cached or up to date.
3.4.2/directory continues to be empty.
- there is no Android builder cache fallback for when the Gradle cache fails to hit.
- the Android builder cache, at least for common tasks, has indeed been eliminated as i stated before.
- the relevant android doc contains outdated info. in particular the cache is not enabled by default as stated there, and the Gradle cache has to be enabled manually.
EDIT 3: user tir38 confirmed that the Android builder cache is obsolete and has been eliminated with this find. tir38 also created this issue. thanks!