Flutter is fantastic for developing anything from small apps to complex applications. I absolutely love using Flutter, but sometimes, it can be a real pain in the you-know-what. Managing different Flutter versions, dealing with various Java versions—yeah, it’s not always smooth sailing. But there’s one error that has truly driven me crazy.
That error is: “Running Gradle task ‘assembleDebug’…”.
Even after hours of searching, it feels like there’s a ton of misinformation out there. Stack Overflow? Not much help either. Most of the solutions you find might work on Linux or Mac but fail miserably on Windows.
After spending countless hours troubleshooting, I’ve finally figured out how to fix this problem for good, and I’m here to show you a step-by-step guide to solving it—no matter what platform you’re on. Let’s get this figured out!
Why Your Flutter App Gets Stuck at “Running Gradle task ‘assembleDebug’…”
If you’ve ever worked with Flutter and got stuck at the dreaded “Running Gradle task ‘assembleDebug’…” message that feels like it’s never going to end—trust me, I’ve been there. It’s one of the most frustrating things about working with Flutter. But the good news is, there are reasons for this issue—and yes, there are solutions!
What’s Causing This?
- First-Time Builds
If you’re building your Flutter app for the first time (or after clearing the build cache), Gradle needs to download a whole bunch of dependencies. And if your internet connection isn’t great, it can take forever and look like it’s completely stuck. - Outdated or Missing SDK Tools
Sometimes, your Android SDK isn’t fully updated or doesn’t have the necessary tools installed. Since Flutter depends on Android’s build tools, Gradle can’t do its job if something is missing or outdated. - Gradle Cache Issues
Gradle is picky about its cache. If the cache gets corrupted or clogged with old files, it can endlessly try to work through the mess without getting anywhere. - Unaccepted Android Licenses
Flutter requires you to accept all Android licenses to function properly. If you haven’t runflutter doctor --android-licensesand accepted everything, Gradle might get stuck waiting for permission it never gets. - Network Problems
Gradle downloads a lot of stuff during the build process. If your internet connection is slow or unstable, it can lead to painfully long build times—or the process might look like it’s completely frozen. - Emulator Glitches
Sometimes, the problem isn’t even with Gradle itself. An Android Emulator with corrupted data can cause the build to misbehave or hang indefinitely.
Why Does This Keep Happening?
The main issue lies in how Gradle handles dependencies, caches, and external tools. Combine that with slow internet, outdated SDKs, or platform-specific quirks, and you’ve got the perfect recipe for frustration. Flutter builds rely heavily on external systems like Gradle and the Android SDK, so even a tiny problem in one area can throw the whole process off.
Fixing the “Running Gradle task ‘assembleDebug’…” Issue
Alright, let’s get straight to the point. If you’re stuck staring at the “Running Gradle task ‘assembleDebug’…” message for what feels like forever, here’s the fix. Trust me, this works because I’ve been there and tried it all.
Step-by-Step Fix
- Open Your Flutter Project Directory
Navigate to the root of your Flutter project. If you’re using a terminal, justcdinto it. - Switch to the Android Directory
Change to the Android directory inside your Flutter project:
cd android- Clean Gradle
Run this command to clean Gradle:
./gradlew cleanThis will clear out any cached or corrupted files that might be causing the hang-up.
- Build Gradle
After cleaning, build Gradle by running:
./gradlew buildOr, to save time, you can combine the clean and build steps into one command:
./gradlew clean build- Run Your Flutter Project
Now you’re ready to run your project again. If you’re using VS Code, just hit F5, and Flutter will take care of the rest. Keep in mind, the first time Gradle runsassembleDebug, it’s going to take some time. Be patient—it’s normal!
Conclusion
Getting stuck at “Running Gradle task ‘assembleDebug’…” is one of the most annoying parts of working with Flutter, but it doesn’t have to drive you crazy. With the steps I’ve shared, you can fix the issue in no time and get back to doing what really matters—building your app.
Remember, the first Gradle build will always take some time, but once it’s done, everything will run much smoother. Don’t let this error slow you down; now you know exactly how to handle it.
Flutter is an amazing tool, and a little troubleshooting like this is just part of the journey. So, keep building, keep experimenting, and don’t let a stuck Gradle task stop you from creating something awesome! 🚀
FAQ: Common Flutter Gradle assembleDebug Questions
How long should “Running Gradle task assembleDebug” take?
On a first build, it can take 5–20 minutes depending on your internet speed and machine. Gradle downloads all dependencies, SDK tools, and build artifacts from scratch. On subsequent builds, it should take 30 seconds to 2 minutes. If it’s been stuck for more than 20 minutes on a first build, something is wrong — follow the steps above.
What does “Gradle task assembleDebug failed with exit code 1” mean?
Exit code 1 means the Gradle build failed. The most common causes:
- Unaccepted Android licenses — Run
flutter doctor --android-licensesand accept all. - Corrupted Gradle cache — Run
cd android && ./gradlew cleanthen rebuild. - Missing or outdated Android SDK — Run
flutter doctor -vand fix any red items. - Java version mismatch — Flutter requires JDK 17+. Check with
java -version. - Network issues — Gradle needs to download dependencies. If you’re behind a firewall or proxy, configure Gradle proxy settings in
android/gradle.properties.
Flutter build apk —release stuck at “Running Gradle task assembleRelease” — same fix?
Yes! The same solution applies to assembleRelease. The Gradle clean + build steps work for both debug and release builds. Run:
cd android
./gradlew clean
flutter build apk --release“flutter run stuck at running gradle task assembleDebug” — how to stop it?
Press Ctrl+C (or Cmd+C on Mac) in the terminal to kill the stuck process. Then follow the fix steps above before running flutter run again. You can also try running with verbose mode to see where it’s actually stuck:
flutter run --verboseWhat does flutter doctor -v show about Gradle?
Run flutter doctor -v to get a detailed report of your Flutter environment. It will show:
- Flutter version and which channel you’re on
- Android SDK path and installed components
- Android NDK location (if needed)
- Java version (must be JDK 17+ for recent Flutter versions)
- Any issues with your setup that might cause Gradle to fail
Fix every item marked with a red [!] before trying to build again.
Flutter assembleDebug taking too long every time (not just first build)?
If every build is slow (not just the first one), try these:
- Clear the Gradle cache:
rm -rf ~/.gradle/caches/(Mac/Linux) or delete%USERPROFILE%\.gradle\caches(Windows) - Increase Gradle memory: Add
org.gradle.jvmargs=-Xmx4096mtoandroid/gradle.properties - Enable parallel builds: Add
org.gradle.parallel=truetoandroid/gradle.properties - Use
--no-daemonmode to troubleshoot:flutter run -- --no-daemon
Is “Running Gradle task assembleDebug” stuck or just slow?
If the terminal shows the message and the cursor is blinking, it’s likely still working (downloading dependencies). If you see no network activity in your task manager or the process is using 0% CPU, it’s probably stuck. Run flutter run --verbose to see real-time logs and pinpoint where it’s hanging.


Discussion
Share your thoughts and engage with the community