Reputation: 891
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.
Upvotes: 89
Views: 380853
Reputation: 13
Here's what worked for me:
I ensured all paths in my environment variables are set correctly. I had an issue with my SDK paths containing a space.
What I also did:
I toggled Hyper-V off and then on again: (If you use Hyper-V)
- Go to 'Control Panel' > 'Programs' > 'Turn Windows features on or off'.
- Uncheck 'Hyper-V', click 'OK', and restart.
- Re-enable 'Hyper-V' and restart again.
Upvotes: 0
Reputation: 796
Something got wrong with the image saved. Just select "Start emulator with coldboot" in VS code for a fresh restart and will work.
Upvotes: 0
Reputation: 148
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.
Upvotes: 1
Reputation: 91
Goto AVD manager and delete old virtual device and install new Device then it will work.
Upvotes: 2
Reputation: 101
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.
Upvotes: 0
Reputation: 117
Follow these steps:
qemu-system-x86_64
on Task Manager and end task
cmd
and execute this command adb kill-server
It works for me. Good luck
Upvotes: 0
Reputation: 108
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.
Upvotes: 0
Reputation: 3526
For me "wipe data" by going into :
Didn't work.
So I did it the hard way :
Upvotes: 0
Reputation: 714
Check if it already running. Find qemu-system-x86_64
(or similar) on windows task manager, choose end task
. Try launch it again.
Upvotes: 2
Reputation: 2504
It was a storage issue for me. Had to clear up space by deleting junk files and I was able to restart my emulator.
Upvotes: 0
Reputation: 378
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.
Upvotes: 0
Reputation: 460
For anyone struggling even after trying with the other solutions. Try:
adb kill-server
Upvotes: 6
Reputation: 801
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
Upvotes: 18
Reputation: 336
Upvotes: 10
Reputation: 713
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 Studio
Then, I ran flutter run
from VS-Code and it worked!
Upvotes: 1
Reputation: 21
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.
Upvotes: 2
Reputation: 173
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.
Upvotes: 0
Reputation: 141
Here are the reasons I had
Upvotes: 4
Reputation: 574
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:
You can get the emulator ID with the flutter emulators
command:
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.
Upvotes: 2
Reputation: 7
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.
Upvotes: 0
Reputation: 1695
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.
Upvotes: 0
Reputation: 21
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 .
Upvotes: 2
Reputation: 52454
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.
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
Upvotes: 2
Reputation: 101
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.
Upvotes: 10
Reputation: 7996
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.
Upvotes: 0
Reputation: 4847
You need to first install android studio.
Follow these steps (Works for Android Studio 3.5.1)
Select "AVD manager"
There will be a popup now for creating your virtual device.
Upvotes: 0