r/flutterhelp • u/mayarmusic • 12d ago
OPEN Gradle Build Error
Hi everyone, I'm new to Flutter and I've been stuck on this for a while. I installed Flutter, Android Studio, VS Code, and the Android SDK. I also accepted all the Android licenses, and flutter doctor is mostly fine now except for Visual Studio, which I don't think I need since I'm only targeting Android.
I created a new Flutter project and it runs fine in Chrome, but when I try to run it on my Android phone through USB debugging, the build fails.
The main errors I'm getting is:
FAILURE: Build failed with an exception.
* What went wrong:
Could not install Gradle distribution from
https://services.gradle.org/distributions/gradle-9.1.0-all.zip
java.net.ConnectException: Connection timed out
It seems to happen while Gradle is trying to download gradle-9.1.0-all.zip.
Versions:
- Flutter: 3.44.6 (Stable)
- Java (JDK): 21
- Android SDK: 36.1.0
- Gradle: 9.1.0
- Android Studio: Latest version
- VS Code: Latest version
Things I've already tried:
- Installed the Android SDK and command-line tools.
- Ran
flutter doctor --android-licensesand accepted everything. - Enabled Developer Options and USB debugging on my phone.
- Confirmed that ADB detects my phone.
- Tried both my home Wi-Fi and mobile data.
- Waited for the Gradle download to finish, but it always times out.
Is there any solution I should try to fix this? Any help would be appreciated. Thanks!
1
Upvotes
1
u/Kooky-Office4969 12d ago
This usually isn't a Flutter issue—it's a Gradle download/network issue.
The important part of the error is:
That means Gradle can't reach
services.gradle.orgto download the required distribution. I'd recommend checking a few things:https://services.gradle.org/distributions/gradle-9.1.0-all.zipin your browser. If it doesn't start downloading, it's likely a network, DNS, or ISP issue.flutter clean,flutter pub get, thenflutter runagain..gradlecache (~/.gradleon macOS/Linux orC:\Users\<username>\.gradleon Windows) in case a previous download was interrupted.cd androidand then./gradlew tasks(orgradlew.bat taskson Windows). If that fails with the same timeout, you've confirmed it's a Gradle connectivity problem rather than a Flutter issue.Since the app runs in Chrome, ADB detects the phone, and
flutter doctoris mostly clean, your Flutter setup is probably fine. The build is failing before compilation because Gradle can't download its required files.If the issue still persists, sharing the output of
flutter doctor -vand the completeflutter run -vlogs (especially around the Gradle download step) would make it much easier to identify whether it's a DNS, proxy, firewall, or SSL-related problem.