Problems when running gradle task 'assembledebug' in Flutter, stuck

- 👤 Andrés Cruz

🇪🇸 En español

Problems when running gradle task 'assembledebug' in Flutter, stuck

Gradle starts running and keeps running and running until the end of time and NEVER finishes running... So, in this article, we'll see how to resolve the running Gradle task assembleDebug in Flutter.

How to solve the problem when executing the assembleDebug Gradle task in Flutter?

You can try the following things:

Windows Firewall was causing this problem. After I temporarily disabled it, the problem went away. It's worth a try.

If this didn't work for you, you can try the following

Open your flutter project directory.

Change directory to the android directory in your flutter project directory cd android and run

./gradlew clean

And then:

 ./gradlew build 

Or you can combine both commands with just

./gradlew clean build.

Now run your flutter project. If you are using vscode, press F5. The first time Gradle runs debugging the assembly it will take time and this should solve the problem.

If the above operation results in:

./gradlew The operation couldn’t be completed. Unable to locate a Java Runtime

It means you need to set JAVA_HOME in your Path, on MacOS it would be something like:

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home

In summary:

A very common problem when developing applications in Flutter is that, when running in an Android project, it stops responding and gets stuck; for this, we have the following commands:

Open your flutter project folder.

  • Change directory to the android directory in your flutter project directory cd android
  • Clean gradle: ./gradlew clean
  • Compile gradle ./gradlew build
  • Or you can combine both commands with just ./gradlew clean build

Now run your flutter project. If you are using vscode, press F5. The first time gradle runs assembleDebug it will take time.

This command gives a lot of information about whether there are any missing configurations, packages, etc about your project; so, in case the execution fails, you must be aware of possible errors that it throws.

I agree to receive announcements of interest about this Blog.

We're going to talk about a potential bottleneck that can occur when you try to run a Flutter app on Android, where the app gets stuck on "Running Gradle task 'assembleDebug'..." and how you can fix it.

| 👤 Andrés Cruz

🇪🇸 En español