How to configure gradle to work "offline" (using cached dependencies)

NullPointerException picture NullPointerException · Aug 23, 2015 · Viewed 89.7k times · Source

I have a command line apk generator which compiles a lot of APKs using the same source code, so these apps have the same dependencies.

In the gradle documentation I can see this:

The Gradle project needs network connectivity to download dependencies.

I know that it is possible to configure gradle to work offline and not download the same dependencies that it has downloaded for other apks. How can this offline mode be activated?

Answer

iagreen picture iagreen · Aug 24, 2015

Gradle does a good job of avoiding re-downloading artifacts, but you can pass --offline to Gradle to prevent from accessing the network during builds.

e.g.

gradle --offline build

If it needs something from the network that it doesn't have, instead of attempting to fetch it, your build will fail.