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

Android Studio (v. 3.6.1 and above)

You can make gradle to build your apps fully offline by activating this option:

Here is the screenshot from the Android Studio Gradle Toolbar 👇

disconnect gradle sync


Android Studio

In Android Studio you can make gradle to build your apps fully offline by activating this option:

Settings -> Build, Execution, Deployment -> Build tools -> Gradle

enter image description here


Gradle CLI

In Gradle command line interface you can get this done by using --offline flag.

Specifies that the build should operate without accessing network resources.


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.