Flutter App stuck at "Running Gradle task 'assembleDebug'... "
Here is solution in my case.
- Open your flutter Project directory.
- Change directory to android directory in your flutter project directory
cd android
- clean gradle
./gradlew clean
- Build gradle
./gradlew build
or you can combine both commands with just./gradlew clean build
- Now run your flutter project. If you use vscode, press F5. First time gradle running assembleDebug will take time.
PS: Delete gradle in case of all that steps don't work
flutter run -v
showed that I was stuck on
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
This was going to take hours, as for some reason the download speed was ~10kB/s on a decent DSL connection.
Solution:
- Interrupt gradle build
- Download the required gradle zip from a fast mirror. e.g. https://distfiles.macports.org/gradle/gradle-5.6.2-all.zip
- Copy
gradle-5.6.2-all.zip
toC:\Users\ <MyUsername>\.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb
(of course the last folder will have a different name on your PC) flutter run
and voilà.
In my case, Windows Firewall was causing this problem. After I disabled it temporarily the problem was gone. Worth giving it a try. Good luck!
If you are on Windows: try adding firewall exceptions to your Android Studio.
- Go to:
Control Panel\System and Security\Windows Defender Firewall\Allowed apps
- Hit the button:
Allow another app
- Add your new firewall exceptions:
studio.exe and studio64.exe
I hope this can be useful for you too.