Gradle build doesn’t download dependencies

We Are Going To Discuss About Gradle build doesn’t download dependencies. So lets Start this Java Article.

Gradle build doesn’t download dependencies

  1. Gradle build doesn't download dependencies

    System caches the dependent jars so it won't be downloaded again and again.
    If your goal is to just see the downloads of the dependencies then you can force it to redownload.
    Remove any dependency caches stored locally [1]

  2. Gradle build doesn't download dependencies

    System caches the dependent jars so it won't be downloaded again and again.
    If your goal is to just see the downloads of the dependencies then you can force it to redownload.
    Remove any dependency caches stored locally [1]

Solution 1

System caches the dependent jars so it won’t be downloaded again and again.

If your goal is to just see the downloads of the dependencies then you can force it to redownload.

Remove any dependency caches stored locally [1]

$ rm -rf ~/.gradle/caches/

Then restart your build

$ gradlew clean build

You could also force a dependency update with [2]

$ gradlew --refresh-dependencies

[1]https://docs.gradle.org/current/userguide/dependency_management.html#sec:dependency_cache
[2]https://docs.gradle.org/current/userguide/dependency_management.html#sub:cache_refresh

Original Author JBirdVegas Of This Content

Solution 2

The solution that helped in my case:

File -> Invalidate Caches/Restart...

Original Author Artem Botnev Of This Content

Solution 3

I’m using IntelliJ 2018.2.3 and Gradle was not downloading dependencies for me.

I found that I had to uncheck the ‘Offline work’ box in the Gradle settings to get it to download them. I’m not sure how this box became checked because I didn’t check it (honest).

EDIT: In IntelliJ 2021.2.1 Offline Mode can now be toggled in the Gradle tool window, as shown below:

enter image description here

Original Author Joman68 Of This Content

Solution 4

If your project builds successfully some time it may be gradle download problem with a current proxy.
Gradle has it’s own dependency management system similar to maven. I think parts of the gradle publish plugin are backed by maven in some way (not verified). Regardless you shouldn’t have to worry about that level of depth, gradle will handle it. Your problem is setting up the proxy. You just need to set some variables in $projectDir/gradle.properties, for example:

#http proxy setup
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

This can be used to download dependencies without proxy. If you want to use a proxy for you can use the code as below instead of above code.

systemProp.https.proxyPort=3128
systemProp.http.proxyHost=192.168.16.2
systemProp.https.proxyHost=192.168.16.2
systemProp.http.proxyPort=3128

Proxy port and host can be changed as you want.

Original Author Randika Wanninayaka Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment