Attempting to install build-tools-23.0.2 using the echo y | android update sdk --no-ui --all --filter "build-tools-23.0.2" command will result in the following error message:
Error: Ignoring unknown package filter 'build-tools-23.0.2'
Warning: The package filter removed all packages. There is nothing to install.
Please consider trying to update again without a package filter.
You can work around this by running this command first:
echo y | android update sdk --no-ui --all --filter "tools"
This works but it adds a minute or so to every build.
Is there a way to do it so that the results are cached? Or can the container simply be updated with the latest tools so we don’t need to do this at all?
@frank Is there any way to cache this update? It’s adding 4 minutes onto our builds every time. And/Or is there any timeline for adding build tools 23.0.2 to the preinstalled packages? It’s been out for several months now
this adds roughly 21 seconds to the build not 1-2 mins… or even 4 like some people are saying…
if you are redownloading the build tools each build you DO NOT have circleci configured properly.
the dependencies are supposed to be cached. My build runs a step called restore cache for 17 seconds, but after that 17 seconds the same script that usually takes over 1 minute to download dependencies just does a filesystem check that the cache has not been invalidated and is present and continues on, takes 9 seconds. My Build command that used to take 2:50 + to download gradle and build the apk is about 1 minute quicker as it no longer needs to download gradle.
this isnt exactly what im using but it gives you the jist…
in a bash script
if [ ! -e BTOOLS]
echo "Cache invalidated updating sdk"
echo y | android update sdk -u -a -t "tool"
echo y | android update sdk -u -a -t "build-tools-23.0.2"
fi
echo “Cache restore complete, sdk updated”
you either see it say invalidated then download everything and then say cache restore complete or after 1 successful build with dependency download + save and after that it will only say echo cache restored sdk updated and take SECONDS to get there…
you also need to add
dependencies:
cache-directories:
- "/usr/local/android-sdk-linux/build-tools
- “/usr/local/android-sdk-linux/extras”
- “~/repoName/.gradle”
in your YAML so that circleci knows to save the files you updated the sdk with for the next container you are given.
circleci’s support… and documentation is TERRIBLE.
Leveraging gundal’s answer, here’s what I now have. No additional script is required.
dependencies:
pre:
- if ! $(grep -q "Revision=24.4.1" $ANDROID_HOME/tools/source.properties); then echo y | android update sdk -u -a -t "tools"; fi
- if [ ! -e $ANDROID_HOME/build-tools/23.0.2 ]; then echo y | android update sdk -u -a -t "build-tools-23.0.2"; fi
cache_directories:
- /usr/local/android-sdk-linux/tools
- /usr/local/android-sdk-linux/build-tools/23.0.2
Actually, it’s probably not required now that circle has added support for 23.0.2. Yay!
But Google has already moved to 23.0.3. The instructions above can be modified to work for that version (and whatever future versions Circle hasn’t supported yet).
I think it is actually required because my build failed without adding the config you suggested. Either I’m doing it wrong, or the documentation doesn’t actually reflect the current status.