How to preinstall and setup all build dependencies gradle requires ahead of time?

I need to run automated Android builds on a VM that has no access to the outside world.
Unfortunately, when running gradle for the first time to create a build, it starts downloading various packages and also seems to set up some variables/environment that I am not aware of.

I already tried pre-installing the .gradle/ directory at %USERPROFILE%.gradle, with all the zips, pom and jar files, but still there is something missing. This is the error I am now seeing on my VM:

A problem occurred configuring root project ‘player_activity’.

Could not resolve all dependencies for configuration ‘:classpath’.
Could not download gradle.jar (com.android.tools.build:gradle:2.1.2)
Could not get resource ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.2/gradle-2.1.2.jar’.
Could not HEAD ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.2/gradle-2.1.2.jar’.
jcenter.bintray.com

Thanks.

Did you try to run with the command line option --offline?

I tried the recipe here: Build Gradle repository for offline development - Stack Overflow

On your connected machine you run the python script and it will download everything into .gradle_home, then create a typical JAVA dependency repo from it.
This works for me on my simulated environment, but when running this on my server, it still wants to install a package from the cloud, although this package is in the cache (.gradle_home) as well as in the local repo:

  • What went wrong:
    A problem occurred configuring project ‘:playeractivity’.

Could not download hamcrest-core.jar (org.hamcrest:hamcrest-core:1.3): No cached version available for offline mode

In my repo the package is under …\org\hamcrest\hamcrest-core\1.3 while in the cache folder it’s under …\org.hamcrest\hamcrest-parent\1.3

So the repo introduced an additional layer between ‘org’ and ‘hamecrest’… maybe it should be ‘org.hamcrest’ instead, like the error message suggests. Will try this asap…

You can take a look at ivypot-gradle-plugin. I haven’t tried it personally, however, after a talk with its author at the conference it could be useful in your case.

1 Like

It works in most cases. A couple of edge cases I could not solve as yet, but feel free to leave issue on Github and I’ll try to help.

@dschwabe, I am about a year late, but have you solved it?
I am having the exact same issue :confused: