2

We have a project template, cleaned, without being compiled it only needs 5mb of disk space. On our Continuous Integration system, the template is being copied for each of our projects and after that, it's being changed by a script which prepares the template with the code and project properties differences of each project. Once it is prepared, it is being compiled.

All our projects have the same dependencies. And every time the template is copied and prepared to be a different project is downloading again the same dependencies. Today we experienced a very rare and dangerous problem derived from that. All of our compilations starting to fail because Gradle was not able to download a dependency:

> Could not resolve com.github.mobfox:MobFox-Android-SDK-Core:3.2.4.
> Could not get resource 'https://jitpack.io/com/github/mobfox/MobFox-Android-SDK-Core/3.2.4/MobFox-Android-SDK-Core-3.2.4.pom'.
> Could not GET 'https://jitpack.io/com/github/mobfox/MobFox-Android-SDK-Core/3.2.4/MobFox-Android-SDK-Core-3.2.4.pom'.
> Read timed out

Because of that, I need to know how can I definitively achieve that Gradle download only ONE time all the dependencies, and not every time I copy the template and prepare it for being another project. As I'm copying the template to a new folder and I rename the app and some other project things, Gradle is creating a new cache folder for it on Gradle cache directory. Is there a way to tell Gradle the exact directory route where the Gradle dependencies should be stored and searched every time the app is being compiled?

halfer
  • 19,824
  • 17
  • 99
  • 186
NullPointerException
  • 36,107
  • 79
  • 222
  • 382

1 Answers1

0

Probably you can use --offline with the gradlew command which you might be using to build the apk on CI/CD

Here are the details.

Gradle does a good job of avoiding redownloading artifacts, but you can pass --offline to grade to prevent from accessing the network during builds. If it needs something from the network that it doesn't have, instead of attempting to fetch it, your build will fail.

lib4backer
  • 3,337
  • 3
  • 18
  • 16