Flutter-intellij: `Running 'gradle assembleDebug'` forever...

Created on 14 May 2017  ·  30Comments  ·  Source: flutter/flutter-intellij

Steps to Reproduce

  1. Create a new Flutter project
  2. Start the Android emulator.
  3. Click the 'Run' button.

The console says Launching lib\main.dart on Android SDK built for x86 64 in debug mode...

The background tasks thing says Running 'gradle assembleDebug'..., and then it just spins forever, never getting anywhere. There doesn't seem to be any way to see the gradle output either so I have no idea why it isn't working.

After about 5-10 mins exactly 5 mins (you should definitely reduce that timeout to something saner) the console says:

Observatory connection never became ready.
Application finished.

Version info

[√] Flutter (on Microsoft Windows [Version 10.0.15063], channel alpha)
    • Flutter at C:\Users\Tim\Flutter\flutter
    • Framework revision dc4ca8db83 (3 days ago), 2017-05-11 15:33:29 -0700
    • Engine revision f99d3ef108
    • Tools Dart version 1.23.0-dev.11.11

[√] Android toolchain - develop for Android devices (Android SDK 25.0.3)
    • Android SDK at C:\Users\Tim\AppData\Local\Android\sdk
    • Platform android-25, build-tools 25.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version: OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[√] Android Studio (version 2.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Gradle version 3.2
    • Java version: OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[√] IntelliJ IDEA Community Edition (version 2017.1)
    • Dart plugin version 171.4424
    • Flutter plugin version 13.1

[√] Connected devices
    • Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 7.1.1 (API 25) (emulator)

▣ platform-android ❖ platform-windows

Most helpful comment

All 30 comments

I found someone had the same problem and was suggested to try flutter run -v, which outputs this for me:

[ +180 ms] Building APK
[ +102 ms] Using gradle from C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\gradle.bat.
[   +2 ms] Running 'gradle assembleDebug'...
[   +1 ms] [android\] C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\gradle.bat -Ptarget=C:\Users\Tim\Dropbox\Projects\roomcat\lib/main.dart assembleDebug
[+1497 ms] Incremental java compilation is an incubating feature.
[  +13 ms] The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
[   +1 ms]      at build_btkhg9nedf0diuf9vzsb6xtya$_run_closure2.doCall(C:\Users\Tim\Dropbox\Projects\roomcat\android\build.gradle:20)
[ +202 ms] :app:flutterBuildX86Jar UP-TO-DATE
[   +6 ms] :app:preBuild UP-TO-DATE
[   +1 ms] :app:preDebugBuild UP-TO-DATE
[   +2 ms] :app:checkDebugManifest
[        ] :app:prepareDebugDependencies
[   +4 ms] :app:compileDebugAidl UP-TO-DATE
[   +9 ms] :app:compileDebugRenderscript UP-TO-DATE
[   +5 ms] :app:generateDebugBuildConfig UP-TO-DATE

And then it freezes. In this case forever.

@jakobr-google may have debugging tips.

The next tasks after :generateDebugBuildConfig are :flutterDependenciesDebug and :flutterBuildDebug, where we generate the Dart snapshots. They take somewhere around 5s - 15s on my machines.

You can debug further by going into the android directory and running gradle --debug assembleDebug (you can find Gradle in your Android Studio folder). This should tell you exactly which command it's running when it hangs.

cc @skybrian

So when I ran gradle from the command line it seemed to complete that stage
successfully, however it also popped up a Windows firewall "do you want to
allow blah blah" message, so I suspect this is a firewall issue.

It's a bit weird because I did try disabling the Windows firewall before to
no avail, but maybe I didn't turn it off properly.

It'd be good if the Observatory didn't rely on TCP for local communication.
Maybe it can fall back to named pipes or whatever IPC Windows uses.

Anyway give me a few days and I will investigate some more (no time now).

I don't think this is Gradle; that's probably just the last message printed. There is a timeout for the IDE failing to connect to Observatory and that's 5 minutes.

I'm a bit surprised that a firewall blocks connections to localhost. (Assuming it is localhost; it's whatever websocket URL is specified by flutter run.) Printing a message saying we failed to connect to host:port before trying again seems like the right thing to do here, as far as error messages are concerned.

Looking at the code again, it looks like I got that wrong.

Observatory connection never became ready.

This means the flutter run command never reported the Observatory URL. The command checks the Observatory URL before passing it on to the IDE, so I think it's failing to connect on the flutter side.

FYI @tvolkert who was looking at a possibly related connection issue yesterday.

I tried this again today with no changes and it worked perfectly. Race condition seems plausible.

Great - closing this, then. Feel free to reopen if you see this again!

Yay! Thanks all for the help. 👍

I encountered this bug on Linux, but restarting IntelliJ resolved it., so maybe it is not actually solved. I guess it works fine now but it certainly just happened and I was waiting 5 minutes for the app to run ;). I just set up Flutter and the dev environment from scratch and couldn't build the demo app on my device.

Steps to Reproduce

  1. Start a new flutter project (in my case: flutter create hello_world)
  2. Run the flutter app on your device (in my case HUAWEI Y550 L01)

I expected the app to run, however only
"Launching lib/main.dart on HUAWEI Y550 L01 in debug mode...
Observatory connection never became ready."
was printed to the terminal. It looks like gradle:AssembleDebug was taking a while as well.

Version info

[✓] Flutter (on Linux, locale en_US.UTF-8, channel alpha)
• Flutter at /home/andreas/Documents/Andreas/Programmieren/flutter
• Framework revision d36e2f6191 (22 hours ago), 2017-06-21 15:09:10 -0700
• Engine revision b0dee695ec
• Tools Dart version 1.24.0-dev.6.7

[✓] Android toolchain - develop for Android devices (Android SDK 25.0.3)
• Android SDK at /home/andreas/Android/Sdk
• Platform android-25, build-tools 25.0.3
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] Android Studio (version 2.3)
• Android Studio at /opt/android-studio
• Gradle version 3.2
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] IntelliJ IDEA Community Edition (version 2017.1)
• Flutter plugin version 14.0
• Dart plugin version 171.4694.29

[✓] Connected devices
• HUAWEI Y550 L01 • b4305293246b • android-arm • Android 4.4.4 (API 19)

I am experiencing the same issue. I get the following error when I try to run a blank flutter project:

Launching libmain.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Observatory connection never became ready.
Application finished.

I am new to Flutter and Dart. Was following the steps mentioned in the Flutter Getting Started Guide: https://flutter.io/getting-started/

Android Studio, Flutter SDK and IntelliJ IDEA are properly configured.

flutter doctor returns the following:

[√] Flutter (on Microsoft Windows [Version 6.1.7600], locale en-IN, channel alph
a)
• Flutter at C:flutterflutter
• Framework revision b156a0f054 (7 days ago), 2017-08-11 22:01:40 -0700
• Engine revision fef7d827d6
• Tools Dart version 1.25.0-dev.9.0

[√] Android toolchain - develop for Android devices (Android SDK 25.0.2)
• Android SDK at C:UsersShoumikAppDataLocalAndroidsdk
• Platform android-25, build-tools 25.0.2
• Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[√] Android Studio (version 2.3)
• Android Studio at C:Program FilesAndroidAndroid Studio
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[√] IntelliJ IDEA Community Edition (version 2017.2)
• Flutter plugin version 16.0
• Dart plugin version 172.3757.55

[√] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (A
PI 26) (emulator)

Android Studio Log suggests the following:

[1422750] INFO - tools.idea.ddms.adb.AdbService - Successfully connected to adb
2017-08-18 21:50:08,613 [1467656] INFO - ellij.vfs.persistent.FSRecords - Contents:16384 of 159278908, reuses:303 of 871192 for 915
2017-08-18 21:50:25,575 [1484618] INFO - .diagnostic.PerformanceWatcher - Unindexed files update took 74395ms; general responsiveness: 7/72 sluggish, 2/72 very slow; EDT responsiveness: 0/72 sluggish, 3/72 very slow

IntelliJ IDEA log shows the following:

[1114566] INFO - r.run.daemon.DaemonConsoleView - [{"event":"app.start","params":{"appId":"361063b6-f5cb-443b-9a38-a1483ba14907","deviceId":"emulator-5554","directory":"C:\Users\Shoumik\IdeaProjects\myapp","supportsRestart":true}}]
2017-08-18 22:19:35,235 [1115265] INFO - r.run.daemon.DaemonConsoleView - [{"event":"app.progress","params":{"appId":"361063b6-f5cb-443b-9a38-a1483ba14907","id":"0","progressId":null,"message":"Initializing gradle..."}}]
2017-08-18 22:19:36,992 [1117022] INFO - r.run.daemon.DaemonConsoleView - [{"event":"app.progress","params":{"appId":"361063b6-f5cb-443b-9a38-a1483ba14907","id":"0","progressId":null,"finished":true}}]
2017-08-18 22:19:36,998 [1117028] INFO - r.run.daemon.DaemonConsoleView - [{"event":"app.progress","params":{"appId":"361063b6-f5cb-443b-9a38-a1483ba14907","id":"1","progressId":null,"message":"Resolving dependencies..."}}]
2017-08-18 22:24:33,470 [1413500] INFO - r.run.daemon.DaemonConsoleView - [{"id":0,"result":true}]
2017-08-18 22:24:34,127 [1414157] INFO - .flutter.run.daemon.FlutterApp - StopApp myapp (Run)
2017-08-18 22:28:17,979 [1638009] INFO - ide.actions.ShowFilePathAction -
Exit code 1

I got a similar issue on Ubuntu 16.10 64 bits (no connection with Observatory)

Steps to reproduce

  1. Install prerequesites if not done : flutter sdk, intellij idea (mine is community), android sdk
  2. Start a new project from inside Intellij Idea
  3. Launch the android emulator (can be done from another terminal)
  4. cd into the android folder from the Intellij Idea terminal
  5. run gradle --debug assembleDebug > ~/Documents/temp/flutter-app-building

I've attached the flutter-app-building.txt (from the previous command) and the flutter_doctor.txt files.
flutter-app-building.txt
flutter_doctor.txt

Did anyone ever get a fix for this? I'm attempting to follow the Get Started: Test Drive tutorial on flutter.io but am running into the same issues on Windows 10.

After timeout, the following is displayed in the Android Studio console:

  • Error running Gradle:
    Unable to download needed Android SDK components, as the following licenses have not been accepted:
    Android SDK Build-Tools 26.0.2

To resolve this, please run the following command in a Terminal:
flutter doctor --android-licenses

Running _flutter doctor --android-licenses_ fails with the message:

sdkmanager --version failed: 1

I would really like to take a good look at Flutter but have no idea what to do next.

Thanks for any help.

@maxapps can you file a new issue so this one doesn't get overloaded, and include the full output of flutter --verbose doctor?

Thanks!

@tvolkert I would be happy to but I did some google research and somehow managed to get it working. I went to SDK Tools in Android Studio, and checked the box next to Android SDK Build-Tools 28-rc1 (previously, it had a dash). Something was downloaded and a dialog allowed me to answer affirmative to the license question. I don't really know if anything downloaded was actually needed or it was just the process of creating/updating some license file.

Anyway, it's now working.

What I've learned in VS Code is that if you modify a file in the project while assembleDebug is running, it will spin forever.

open project structure or project sittings
and add project SDK
this SDK is default for all project module

this way done with me

run this to get the problems in details

your_app_folder\android\gradlew.bat -Pverbose=true-Ptarget=your_app_folder_again\lib\main.dart -Ptrack-widget-creation=true -Pfilesystem-scheme=org-dartlang-root
-Ptarget-platform=android-arm assembleDebug --status

in my case :

No Gradle daemons are running.
PID STATUS INFO
6952 STOPPED (by user or operating system)

Only Daemons for the current Gradle version are displayed. See https://docs.gradle.org/6.1.1/userguide/gradle_daemon.html#sec:status

This problem occurred on my system because of the Zen Kernel.

I installed the Linux-LTS kernel and started system using this.

Then my project backed to compile again.

@btd1337 I'm having the same problem with my distro, have you been able to fix it without having to change to LTS?

What worked for me:

  • Deleted flutter sdk folder and downloaded a new one \__(0.O)__/

After a bit of research I was suspecting that the slow internet link was the cause, and I kind of verified this by checking the network activity of my computer after running the flutter run -v and it was consuming all bandwidth _(max download speed here was 224KB/s)_.

I was a bit more patient and I started getting this error:

[+534089 ms] FAILURE: Build failed with an exception.
[   +1 ms] * What went wrong:
[        ] A problem occurred configuring root project 'android'.
[        ] > Could not resolve all artifacts for configuration ':classpath'.
[        ]    > Could not download kotlin-compiler-embeddable.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.50)
[        ]       > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.3.50/kotlin-compiler-embeddable-1.3.50.jar'.
[        ]          > Read timed out

It tries to download resources configuring the project, so it might happen just for the first time.

A bit sad but that's it, hope this help someone else. cheers!

I faced the same issue while running my flutter app in the emulator.
For me problem was solved following these steps

  • cd android && ./gradlew --stop (to stop running gradle deamons)
  • running the app from intellij /studio

@btd1337 I'm having the same problem with my distro, have you been able to fix it without having to change to LTS?

No, just changing Kernel work for me.

Linux Zen => Linux LTS

This problem occurred on my system because of the Zen Kernel.

I installed the Linux-LTS kernel and started system using this.

Then my project backed to compile again.

Same for me.. after upgrading to Kernel version 5.5 my 'gradle assembleDebug' task is running forever. Booting the System with Kernel 5.4 and everything works fine again.

Edit: "If you are exerpiencing this issue, please use Flutter master channel for now, or downgrade your kernel. The team is evaluating how and when to bring this fix to stable actively." - Reference: https://github.com/flutter/flutter/issues/49185

This issue is majorly encountered in the beginning only. After that your machine adapts to Android Studio (this also reduces the heating).
So, bear with it for a while and then everything would be relatively smoother.
Also, performing hot restart saves your time many a times.

Same goes with the emulators.

Was this page helpful?
0 / 5 - 0 ratings