Connecting to the VM Service is taking longer than expected

397 Views Asked by At

I am trying to run a flutter project and am having a series of errors doing so. At first I was having an error:

FAILURE: Build failed with an exception.

* Where:
Settings file '<project>\android\settings.gradle' line: 26

* What went wrong:
Plugin [id: 'com.android.application', version: '7.3.0', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (None of the included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:7.3.0')
  Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository

This got fixed after some tweaking by looking in other SO articles.(no idea what fixed it)

Now the app is running but it gets stuck at the start only with a message:

Connecting to the VM Service is taking longer than expected...
Still attempting to connect to the VM Service...
If you do NOT see the Flutter application running, it might have crashed. The device logs (e.g. from adb or XCode) might 
have more details.
If you do see the Flutter application running on the device, try re-running with --host-vmservice-port to use a specific 
port known to be available.

Went through a lot of issues on flutter github repo related to this but there is no proper solution for this. It is happening for windows(win11) system and also while running app in mobile emulator.

1

There are 1 best solutions below

0
spydon On

Remove the android directory and re-create it with flutter create . --platform=android, there seems to be something wrong/corrupt/old in there.