76

I'm unable to debug using VSCode for Flutter. I'm using Windows and I'm trying to use an Android emulator.

I have attempted to reinstall Flutter, Android SDK and VSCode to fix the issue, as well as tried setting environment variables.

This is the error that I get when launching debug mode. Failed to launch emulator: Error: Emulator didn't connect within 60 seconds

Are there any better emulators that I can use for both Android and IOS, because I don't even know where to begin with IOS emulators. I'm new to app development and want to get started making applications for both devices.

SNag
  • 17,681
  • 10
  • 54
  • 69
f1t3
  • 761
  • 1
  • 5
  • 3
  • 1
    `flutter emulators` to see available devices – Ethan Hunt Jun 07 '19 at 02:59
  • 1. Restart 'terminal' windows 2. Restart Android Studio, stop emulator, wipe data, run again 3. Make sure you are getting some output or error in terminal windows, if not start with step 1 and 2. – TheTechGuy Jan 26 '22 at 01:52

34 Answers34

76

i had same problem, i tried to stopping emulator based on Answer of Rahul Shukla:

Steps:

Open Android Studio Tools -> AVD Manager Virtual Device -> Actions (Refer Image) Click On Stop Now Start Emulator Now it's working fine :)

but it not work for me. i test another way. i use these steps:

  • Open Android Studio Tools -> AVD Manager Virtual Device -> Actions Click On Wipe data

Now Start Emulator and Enjoy it!!

Community
  • 1
  • 1
Hossein Vejdani
  • 961
  • 8
  • 19
  • If you is using linux, you should give the user permission from the directory /dev/kvm. – Marcelo Rebouças Aug 05 '20 at 14:18
  • 3
    I'd same problem and "Cold Boot Now" option works fine. No need to wipe device data. – Lutti Coelho Jun 18 '21 at 14:41
  • I killed qemu process from task manager :D seems easier – Suj May 12 '22 at 08:11
  • Wipe data worked for me. Here is a tutorial that visually shows where those options are on latest version of Android Studio: [How to fix flutter failed to launch emulator error](https://semicolon.dev/flutter/how-to-run-existing-flutter-app-in-vscode) – InfiniteStack Dec 28 '22 at 22:26
18

Steps:

  1. Open Android Studio
  2. Tools -> AVD Manager
  3. Virtual Device -> Actions (Refer Image)
  4. Click On Stop
  5. Now Start Emulator

Now it's working fine :)

enter image description here

Rahul Shukla
  • 7,365
  • 3
  • 15
  • 26
15

Adding the following variables to $HOME/.bash_profile solved my problem

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Code4Art
  • 741
  • 8
  • 9
9

I've added a user environment variable:

  • Name: ANDROID_HOME

  • Path: Your android folder path, personally it was D:\Android

and restart.

Hope it ll work for you.

Blig
  • 91
  • 1
  • 3
9

enter image description here

  1. Open Android studio and go to AVD manager.
  2. Click on stop
  3. Click on wipe data
  4. Click Cold boot
4

For android emulator there are alternatives like geanny motion.

Since you have AVD installed you could try running from the command line. run flutter devices to get the list of emulators and their id. then run (assuming emulator-5554 is you emulator id) flutter run -v -d emulator-5554

Finally you the option of starting android studio then start your emulator,form the IDE and the run the above command or you even run the app from the IDE.

kenn
  • 1,384
  • 12
  • 19
4

Here are the reasons I had

  1. Out of disk space.
  2. Android Studio didn't launch. I immediately started looking for the problem in VS.
O K
  • 141
  • 3
  • I also had a problem with disk space but VS Code doesn't display a clear error message that directs us to the root cause. What worked for me was trying to start the emulator manually through "flutter emulators --launch flutter_emulator" and I managed to see the root cause. Use "flutter emulator" in order to see the available emulator ids to use with the launch command. – Tales Santos Nov 22 '22 at 12:17
  • because some answers mixed with free space case, actually this is maybe woking but if still not working maybe you should try another answer – toha Jul 09 '23 at 07:04
4

For anyone struggling even after trying with the other solutions. Try:

  1. Quit VS Code
  2. Open your terminal and run adb kill-server
  3. Open VS Code again and attempt to run your app on your emulator.
cigien
  • 57,834
  • 11
  • 73
  • 112
gyosida
  • 450
  • 4
  • 17
2

This is what worked for me. In Android Studio, go to Settings, and select HAXM. Then go to Tools, AVD Manager, and click on the Play button to start your emulator.

enter image description here

Also, make sure you have enabled Hardware Acceleration in your BIOS, if you have not done so yet. Check this post for this matter: Error during installing HAXM, VT-X not working

live-love
  • 48,840
  • 22
  • 240
  • 204
  • I'm not sure why this was marked down? For anyone else like me who could not get the emulator to start - it would hang at the popup loading screen about 30% through and the qemu process would also hang - this was the solution. In my case I didn't have HAXM installed at all. – Rob Mascaro Jul 15 '20 at 05:24
2

Approach of wiping data listed above worked for me , i mentioned those in steps :- Steps:

1.Open Android Studio 2.Tools -> AVD Manager 3.Virtual Device -> Actions 4.Click On wipe data 5.Now Start Emulator 6.Now restart the pc

Restarting the pc is not necessary i just did it as a follow-up, although make sure your android studio is updated because in my case AS was not updated so i think my emulator was not working and VS Code was throwing errors .

2

Try restarting your PC once! It worked for me!

  • 2
    This could have been a comment on the question, not an answer. – Rvy Pandey Aug 31 '20 at 07:20
  • 2
    This is a valid answer. While not an ideal solution, this is the only thing that currently works for me whenever VS Code fails to connect to the emulator, with the message ["Emulator didn't connect within 60 seconds"](https://github.com/Dart-Code/Dart-Code/issues/2773) – Boaz Sep 28 '21 at 18:40
2

I had the same issue on Linux. I resolved it by disabling hardware acceleration for the emulator:

Android Studio -> AVD Manager -> Edit emulator -> Emulated Performance: Changed from Hardware to Software.


Update:

It turns out that while Flutter is unable to launch emulators with hardware acceleration, they launch with acceleration just fine from Android Studio or with the emulator command.

As of April 2020 you can override emulator launch commands for Flutter in VS Code.

In VS Code settings you can search for dart.flutterCustomEmulators, or directly populate your settings.json like so:

settings example

You can get the emulator ID with the flutter emulators command:

enter image description here

Now when you choose this emulator in VS Code it will use the emulator command from the Android SDK rather than the flutter emulator command it usually uses, and it launches and connects successfully as expected.

Merritt
  • 445
  • 1
  • 6
  • 14
2

You can try to wipe the data of the particular device.

Go to -> Android Studio -> Tools -> AVD Manager -> [Select the down triangle on your chosen device] -> Wipe data.

Now retry.

2

Just restart the PC, works every time. It is that simple.

Nandan Wewhare
  • 445
  • 5
  • 11
1

I am using Genymotion 3.0.2., VS Code (version 1.36.1)

You can read about it here - Using Genymotion Emulator with Flutter in VS Code — (Without Android Studio)

Open up Genymotion and go to the ADB Setting section:

Notice how the default selection is “Use Genymotion Android Tools (default)”? With this selection, the emulator is not recognized. genymotion ADB settings

Change it to “Use custom Android SDK tools”, set the SDK location to where your SDK is (in my case it’s at “C:\Program Files (x86)\Android\android-sdk”). Make sure the tick mark (“This folder is valid”) is displayed.

Close the settings box. Now reload your “VS Code” IDE. Emulator now displayed in vs code

Compiler
  • 105
  • 10
1

The problem for me was that Intel HAXM wasn't installed. When I opened AVD Manager through Android Studio and tried to launch the emulator from there (instead of trying through VS Code), it told me that HAXM was required and prompted me to install it. After Android Studio installed HAXM successfully, I could run the emulator from VS Code without any issues.

Nathan
  • 9,651
  • 4
  • 45
  • 65
1

For me, this was happening quite often and cleaning cache was a bit hectic for me as I had to download few files again and again.

What I did was, stopped the AVD from Android Studioenter image description here

Then, I ran flutter run from VS-Code and it worked!

Aajinkya Singh
  • 543
  • 1
  • 6
  • 14
1

Check if it already running. Find qemu-system-x86_64 (or similar) on windows task manager, choose end task. Try launch it again.

Ryde
  • 654
  • 8
  • 23
1

For me "wipe data" by going into :

  • Android Studio
  • Configure
  • AVD Manager
  • Wipe Data

Didn't work.

So I did it the hard way :

  • Delete the emulator
  • Create a new one.
  • You should increase the internal memory of your device.
Julien J
  • 2,826
  • 2
  • 25
  • 28
1

Make sure that vt-x is enabled in your bios

Ricky
  • 61
  • 4
0

You need to first install android studio.

Follow these steps (Works for Android Studio 3.5.1)

  • Choose "Run" in the top menu bar
  • Press on "Select Device"
  • Select "AVD manager"

  • There will be a popup now for creating your virtual device.

Ash Singh
  • 3,921
  • 2
  • 25
  • 30
0

For me, it was "Not enough disk space". Generally, in these situations, you can run Android studio then Tools-> AVD manager and start manually.

If there is a issue then you can see the actual in android studio logs.

Payam Khaninejad
  • 7,692
  • 6
  • 45
  • 55
0

Mine was similar but for iOS and it said Failed to launch iOS Simulator: Error: Emulator didn't connect within 60 seconds . I closed all instances of VS Code, opened the project again and this time it worked.

Gwamaka Charles
  • 1,479
  • 9
  • 12
0

I also had the same problem above when i freshly install AVD API28. I tried all posted solutions in this thread and they didn't work for me.

So, I go to android studio --> AVD manager --> Click the green play button(Launch this AVD in the emulator).

then VSCode can detect the emulator and it works fine.

But, I think it will need to run AVD manually every time we wants to use the emulator.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Htet
  • 27
  • 1
  • 4
0

I am encountering the same problem with the emulator that it is not starting and says:

"Emulator didn't connect"

Solution:

Make sure that your virtual technology (Vf-x) is enabled in the bios setting.

This solves my problem.

svyat1s
  • 868
  • 9
  • 12
  • 21
Abd ur Rehman
  • 183
  • 1
  • 2
  • 15
0

delete AVD and create a new one worked for me.

Mark
  • 370
  • 5
  • 10
0

For some, it might be problem of the emulator and Android API itself. A duplication of the problem mention in Can launch, but not connect, to emulator in VS Code and Android Studio using flutter. I sort it using a API 29 instead of 30. Since API 30 (in Pixel 4) skipped the allow debug mode. Hope it helps for some of you.

MarcoFerreira
  • 195
  • 1
  • 14
0

It was a storage issue for me. Had to clear up space by deleting junk files and I was able to restart my emulator.

Venkatesh A
  • 1,875
  • 1
  • 19
  • 23
0

I am using Lenovo V15 laptop. I chose extreme performance from bios settings. And I encountered this error. When I select intelligent cooling, the problem was solved.

In a nutshell, Replace 'extreme performance' with 'intelligent cooling' in the bios.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32108125) – Jonny Jun 30 '22 at 00:39
0

Follow these steps:

  1. Find qemu-system-x86_64on Task Manager and end task
  2. Open cmd and execute this command adb kill-server

It works for me. Good luck

greeneley
  • 87
  • 7
0

You have multiple devices that are taking a lot of disk space, just delete the ones that you don't need and retry launching your emulator, everything should work fine. you got that error cuz you run out of space with all those emulators.

0

Goto AVD manager and delete old virtual device and install new Device then it will work.

Akshay K
  • 71
  • 5
0

I had the same issue. For me it was low space on C drive. After I cleared some space on C drive, it worked just fine.

0

Something got wrong with the image saved. Just select "Start emulator with coldboot" in VS code for a fresh restart and will work.

Thiago Silva
  • 670
  • 6
  • 18