How to Configure Gradle to Work "Offline" (Using Cached Dependencies)

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

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.

How to build gradle projects completely offline?

I think you are hitting this issue: https://github.com/gradle/gradle/issues/1338

That is, cache items are non relocatable. Copying the whole ~/.gradle folder may not be enough, especially if ~ resolves to a different path than in the original machine (i.e. different user). The full path needs to be exactly the same (with Gradle 5.0).

The issue suggests however that version 6.1 makes the cache relocatable, so perhaps you'll have more luck with a recent version (7.2 is the latest at this point in time).

EDIT: The release notes and these docs confirm that the cache can be copied across deployments as of version 6.1.1.

How can I change gradle to work offline in Android Studio Bumblebee for a Flutter project

I suspect that the project was not properly linked with the gradle.build file when I opened it since it's a flutter project.

To fix this close the project and then go to Open > Then select the build.gradle file. This will then open the project as a gradle project and the gradle pane will appear.

Configuring gradle completely offline

The only option you have is to check out the project on another machine that does have internet access, resolve all dependencies so you have them in the cache (~/.gradle/caches) and then copy the cache directory to the machine that does not have internet access. From thereon Gradle has all dependencies required for your project. Don't forget to run Gradle with --offline.

Alternatively, you could copy of all required JAR files to a specific directory which you reference as flat directory repository.



Related Topics



Leave a reply



Submit