Gradle could not download a dependency

Hello everyone. I run a React Native android project. the build process failed due to the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
   > A problem occurred configuring project ':react-native-edge-to-edge'.
      > Could not resolve all artifacts for configuration ':react-native-edge-to-edge:classpath'.
         > Could not find gradle-8.1.1.jar (com.android.tools.build:gradle:8.1.1).
           Searched in the following locations:
               https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.1.1/gradle-8.1.1.jar

but when I open the https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.1.1/gradle-8.1.1.jar link in a browser, the file will be downloaded successfully. any idea?

gradlew --version output:

------------------------------------------------------------
Gradle 8.10.2
------------------------------------------------------------

Build time:    2024-09-23 21:28:39 UTC
Revision:      415adb9e06a516c44b391edff552fd42139443f7

Kotlin:        1.9.24
Groovy:        3.0.22
Ant:           Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM:  17.0.8 (Microsoft 17.0.8+7-LTS)
Daemon JVM:    C:\Program Files\Microsoft\jdk-17.0.8.7-hotspot (no JDK specified, using current Java home)
OS:            Windows 10 10.0 amd64

This most often means you either have some Firewall or AntiVirus intervening, or you need to use a Proxy to talk to the outworld but did not configure Gradle to use it.

Running with --refresh-dependencies and --info or --debug might give more hints.

1 Like

The --refresh-dependencies option, solved my problem. Thank you so much @Vampire

1 Like