Failed to launch emulator: Error: Emulator didn't connect within 60 seconds
AndroidIosFlutterVisual Studio-CodeEmulationAndroid Problem Overview
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.
Android Solutions
Solution 1 - Android
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!!
Solution 2 - Android
Steps:
- Open Android Studio
- Tools -> AVD Manager
- Virtual Device -> Actions (Refer Image)
- Click On Stop
- Now Start Emulator
Now it's working fine :)
Solution 3 - Android
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.
Solution 4 - Android
Solution 5 - Android
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
Solution 6 - Android
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.
Solution 7 - Android
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: https://stackoverflow.com/questions/21635504/error-during-installing-haxm-vt-x-not-working
Solution 8 - Android
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 .
Solution 9 - Android
Try restarting your PC once! It worked for me!
Solution 10 - Android
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.
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.
Solution 11 - Android
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.
Solution 12 - Android
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.
Solution 13 - Android
Here are the reasons I had
- Out of disk space.
- Android Studio didn't launch. I immediately started looking for the problem in VS.
Solution 14 - Android
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.
Solution 15 - Android
For anyone struggling even after trying with the other solutions. Try:
- Quit VS Code
- Open your terminal and run
adb kill-server
- Open VS Code again and attempt to run your app on your emulator.
Solution 16 - Android
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.
Solution 17 - Android
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.
Solution 18 - Android
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.
Solution 19 - Android
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.
Solution 20 - Android
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.
Solution 21 - Android
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.
Solution 22 - Android
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!
Solution 23 - Android
Just restart the PC, works every time. It is that simple.
Solution 24 - Android
delete AVD and create a new one worked for me.
Solution 25 - Android
For some, it might be problem of the emulator and Android API itself. A duplication of the problem mention in https://stackoverflow.com/questions/55171897/can-launch-but-not-connect-to-emulator-in-vs-code-and-android-studio-using-flu?rq=1. 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.
Solution 26 - Android
It was a storage issue for me. Had to clear up space by deleting junk files and I was able to restart my emulator.
Solution 27 - Android
Check if it already running. Find qemu-system-x86_64
(or similar) on windows task manager, choose end task
. Try launch it again.
Solution 28 - Android
Make sure that vt-x is enabled in your bios