Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

flutter run hangs for minutes on Running Gradle task 'assembleDebug'

ErrorRunning 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.

  • Applies to Flutter 3.3x stable, Gradle 8.x and 9.x, Android Gradle Plugin 8.x and 9.x, macOS 26, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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=plain
  2. 2Match what you see, then jump to its fix

    1. 1The log stops at Downloading or Resolving, or shows connect timeout linesA download is blocked or crawling behind a proxy or firewallFix
    2. 2Log 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. 3Java heap space or GC overhead limit exceeded, or a build that slows to a crawlThe daemon heap is too small for the projectFix

What does the error look like?

  • Running Gradle task 'assembleDebug'...
  • Downloading https://services.gradle.org/distributions/gradle-8.14-all.zip
  • Java 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.properties

2Fix

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=8080

3Verify

The download lines move on and the task finishes.

cd android && ./gradlew assembleDebug --info

Confirmed by docs.gradle.org

Did this fix it?

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 --status

2Fix

Stop all daemons of that Gradle version and build again.

cd android
./gradlew --stop
cd ..
flutter run

3Verify

A fresh daemon starts and the task runs through.

cd android && ./gradlew --status

Confirmed by docs.gradle.org

Did this fix it?

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.properties

2Fix

Give the daemon more memory in android/gradle.properties, within what the machine can spare.

# android/gradle.properties
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g

3Verify

Stop the old daemon so the new setting applies, then build.

cd android && ./gradlew --stop
cd .. && flutter run

Confirmed by docs.gradle.org

Did this fix it?

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:

Related fixes

Mobile 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 fix

Mobile 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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.