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 org.gradle.caching=true
in 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.
i execute cleanBuildCache
and the 3.4.2/
directory is gone. next i do another clean build
:
- nothing changed: most tasks show
FROM-CACHE
as their status and the build completed at cache-enabled speeds.
- the
3.4.2/
directory is recreated.
- the
3.4.2/
directory is empty (save for 2 hidden, zero length marker files).
conclusions:
- caching of all normal Android builder tasks is handled by Gradle.
- executing
cleanBuildCache
does 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 org.gradle.caching=true
from gradle.properties
and i try a couple of clean build
:
- the builds are slow.
- all tasks show their status as being executed and not cached or up to date.
- the
3.4.2/
directory continues to be empty.
more conclusions:
- 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!
Compiler -> Gradle
to notUse in-process build
. nothing to do with the cache – David T../gradlew clean build --no-build-cache
will force a project build without using the build cache. – ams