flutter run hangs for minutes on Running Gradle task 'assembleDebug'
Running Gradle task 'assembleDebug'...Short answer
That line only says Gradle started; the wait is inside Gradle. Run the same task in the android folder with --info to see where it stops. The usual reasons are a download that cannot get through a proxy or firewall, a stale Gradle daemon, or a daemon that has run out of memory.
Fix it fast
1Find out which cause you have
Run the build by hand with more logging, so the last line before the pause shows what Gradle is waiting for.
cd android ./gradlew assembleDebug --info --console=plain2Match what you see, then jump to its fix
- 1
The log stops at Downloading or Resolving, or shows connect timeout linesA download is blocked or crawling behind a proxy or firewallFix - 2
Log shows nothing new, or Daemon will be stopped at the end of the build after running out of JVM memoryA stale or busy Gradle daemon holds the buildFix - 3
Java heap space or GC overhead limit exceeded, or a build that slows to a crawlThe daemon heap is too small for the projectFix
- 1
What does the error look like?
Running Gradle task 'assembleDebug'...Downloading https://services.gradle.org/distributions/gradle-8.14-all.zipJava heap space
Cause 1 of 3
A download is blocked or crawling behind a proxy or firewall
1Check
The first build downloads a Gradle distribution and all dependencies. Gradle does not read the shell proxy variables by itself; it needs Java system properties.
cat ~/.gradle/gradle.properties 2>/dev/null; cat android/gradle.properties2Fix
Put your proxy in the user gradle.properties using the systemProp prefix, with your own host and port.
# ~/.gradle/gradle.properties
systemProp.http.proxyHost=proxy.example.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.example.com
systemProp.https.proxyPort=80803Verify
The download lines move on and the task finishes.
cd android && ./gradlew assembleDebug --infoConfirmed by docs.gradle.org
Cause 2 of 3
A stale or busy Gradle daemon holds the build
1Check
Gradle reuses background daemons between builds. After a crash or an IDE and a terminal using different JDKs, an old one can linger.
cd android && ./gradlew --status2Fix
Stop all daemons of that Gradle version and build again.
cd android
./gradlew --stop
cd ..
flutter run3Verify
A fresh daemon starts and the task runs through.
cd android && ./gradlew --statusConfirmed by docs.gradle.org
Cause 3 of 3
The daemon heap is too small for the project
1Check
Gradle's own default for the daemon is a 512 MB heap unless the project sets org.gradle.jvmargs.
grep jvmargs android/gradle.properties2Fix
Give the daemon more memory in android/gradle.properties, within what the machine can spare.
# android/gradle.properties
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g3Verify
Stop the old daemon so the new setting applies, then build.
cd android && ./gradlew --stop
cd .. && flutter runConfirmed by docs.gradle.org
How do I stop it coming back?
- Run the first build of a new machine or CI image on a normal network so the downloads are cached.
- Keep the Gradle user home (~/.gradle) between CI runs.
- Run ./gradlew --stop after changing JDK, Gradle version or gradle.properties.
- Use --offline only after dependencies are cached.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Flutter Android build stops with Execution failed for task ':app:…'
Execution failed for task ':app:compileFlutterBuildRelease'.
The line only tells you which Gradle step broke; the task name in the quotes tells you why.
5 causes, each with a fixMobile apps
Flutter's Android build stops: JAVA_HOME is not set
ERROR: JAVA_HOME is set to an invalid directory
The Gradle wrapper script needs a Java runtime and looks in two places: the JAVA_HOME variable, then a java command on PATH.
3 causes, each with a fixMobile apps
flutter doctor cannot find the Java that comes with Android Studio
Unable to find bundled Java version.
Flutter looks for the Java inside Android Studio first, then JAVA_HOME, then any java on PATH.
3 causes, each with a fixMobile apps
Flutter Android build fails with Unsupported class file major version
Unsupported class file major version 65
The number is the Java version that tried to read a file: 61 is Java 17, 65 is Java 21.
3 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
A phone is plugged in over USB but Android Studio and adb do not list it
adb devices prints List of devices attached with nothing below it
adb lists a phone only when four things hold: USB debugging is on, you accepted the computer's RSA key on the phone, the computer has a driver or udev rule for the device, and the cable carries data to a running adb server.
6 causes, each with a fix