stuck in running gradle task 'assembledebug'
Solution 1
Sometimes Its This Error Cause of Sometimes in background flutter downloading gradles files and this was going to take hours. That’s why app can stuck.
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 (Thanks @daniel for the tip)
Now run your flutter project. If you use vscode, press F5. First time gradle running assembleDebug will take time.
Solution 2
When I Try to see Log flutter run -v showed that I was stuck on Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip. This Process Can take Hours. To solve this error you have to follow the below steps.
Interrupt gradle build
Download the required gradle zip from a fast mirror: https://distfiles.macports.org/gradle/gradle-5.6.2-all.zip
Copy gradle-5.6.2-all.zip to C:\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.
that’s it.
Solution 3
There were two reasons for me on Archlinux:
I needed to unset TERM which was set to xterm-256color (reference).
For some reason, flutter stable was not working for me; so I switched to master with: flutter channel master && flutter upgrade. I’ll be able to switch back to flutter stable when the fix in master makes its way into stable (reference).
Solution 4
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