I would like to run WSL2 with my api in it, and an Android emulator to run my app so I can test said api. WSL2 is working perfectly when I'm having Hyper-V activated. Then I'm trying to use Android Studio's emulator and it just hangs, never launching the emulator.
Now, if I deactivate Hyper-V entirely (in the windows features screen and through bcdedit /set hypervisorlaunchtype off) the emulator does launch perfectly, but of course WSL2 won't work now...
I took a look at lots of the topics around here without success. For example How to run Android emulator on windows while using WSL2 with zsh?, Running React Native in WSL with the emulator running directly in Windows or this tutorial. No success so far.
As said I'm using a Ryzen processor.
I was able to find way around it. I'm running Windows 11 Pro, Update 21H2, OS build 22000.51, AMD.
Here is Google documentation how to setup emulator for AMD processors. It requires Hyper-V and WHPX to be disabled. And that does not go in pair with running WSL2.
My setup is:
Android Studio and IntelliJ running under Windows
Docker, DBs and other services running under Ubuntu (WSL2)
What I did:
Enable Hyper-V and WHPX.
Added new Android VM in Hyper-V Manager like that
Find Android VM IP address (I did so by going to running Android wi-fi options) and use adb connect <ip goes here>:5555
If connected properly, it should appear in Android Studio.
I tried to adb connect to the Android from Ubuntu, but it does not work out of the box. Should be doable with some WSL2 > Host redirects, but I currently do not need it and did not research it any further.
Last thing that bugged me was default Android VM resolution (looks like tablet in horizontal orientation). It is possible to adjust it like that.
We probably need to wait for Google to come up with emulator that uses the same emulation type as WSL2.
Things that do not work/are missing (or I do not know how to do it):
cannot change screen orientation on the fly
software keyboard is not showing up when typing (problem when you need to test your UI with it)
no GPU acceleration in Hyper-V (Microsoft disabled it due to secuirty reasons (?) but there seems to be a way to enable it, have not tried it, for my needs default performance is fine)
So, someone gave a great answer on the issue tracker!
https://issuetracker.google.com/issues/202188690#comment18
Basically, as he says, It's being caused by the XSAVE disable code in the WHPX API integration -- target/i386/whpx-all.c -- commenting out this line appears to make it work:
https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/target/i386/whpx-all.c#1768
In the issuetracker, another user has posted already compiled exe files, if anyone needs it. For me it fixed everything, the emulator is now working perfectly properly.
Just add these extra features in windows and you can then run your emulator within wsl2, remember to chown for dev/kvm to your user.
enter image description here
I have been running Android Studio 1.5.1 doing development on a WMWare copy of Windows 2012 R2 and everything works fine. I've been able to run the device emulator with no problems and start various versions of Android running in AVD.
Android Studio 2.x Change
I recently installed Android Studio 2.0 (see image below for exact version).
Now when I attempt to run the emulator nothing happens.
Well, actually I do see a message in the status bar of Studio when I attempt to start the device, but then that message disappears and nothing happens after that.
There is a warning that I need to turn off Hyper-V (see image below), but I don't believe that is possible since this is a VM.
No Longer Possible?
Is it not possible to run the emulator on the VM any more?
More recent versions of the Android Emulator require hardware virtualization support (Intel HAXM).
Unfortunately, most virtual machines do not provide HAXM instructions to the guest (a VM within a VM), so you will be unable to use the emulator within the virtual machine.
I just installed Android Studio 2.1 on my Windows 2008 R2 VM (running VMWare) and I'm happy to report that it is possible to run ARM based AVD (Android Virtual Devices) on the VM.
Steps To Run Arm-based Virtual Device on VMWare
Go to location where you've installed the Android SDKs (in my case it is at %appdata%\Android2\SDK\
If you are in the right place you should see a directory structure and directories like the ones shown in the first image below.
Start the AVD.exe by double-clicking it.
You will see a window like the one in the image below
Take a close look and notice that this is running an ARM(armeabi-v71) image. When you download images you have to download ARM-based images. (no x86 images will work on VM).
Also, you cannot start these images from AVD that launches from Android Studio 2.x
Make sure you have an environment variable named ANDROID_SDK_HOME set to path which is similar to the one at the top of the AVD manager (in image).
Once you do all of this and start an ARM-based image on a VMWare VM it will warn you that it is faster with HAXM but at least the image will run.
Finally, you can see if you attempt to launch your Virtual Device from the AVD Manager in Android Studio then it will warn you that Hyper-V needs to be turned off. Of course you cannot turn Hyper-V off on a VM.
EDIT -- Running Android 7 ARM Image
#mcflysoft asked about running an android 7 ARM image. At first I didn't think it worked, but if you open up your SDK manager and install the exact ARM OS image shown in the following picture, it will run on a Windows VM:
ARM image Containing Google APIs
I tried installing the ARM image that contained the Google APIs and that one would not ever start. There were failures logged which I could see in c:\> adb shell logcat.
Beware : It Is Really Slow
However, running Android 7 seems extremely slow and I don't see a web browser.
Not sure how helpful it may be to you, but you can get it working.
Good luck.
The simplest solution I've found so far is to use a device farm, for example Samsung's device farm:
https://developer.samsung.com/remotetestlab/galaxy/rtlDeviceList.action#444
It's free to use and you can deploy your apps just like in an emulator (Right Click -> Test -> Remote Debug Bridge -> follow the instructions).
And since those are real devices, the speed might be even better than on an emulator on your personal PC.
I've had the same problem so I'll post an answer in the hope that someone might find this useful in the future. I can run Android Studio in my VM but when I try to start up an emulator, I can't download an image due to "Your CPU does not support required features (VT-x or SVM)"
Although I didn't get a virtual device up and running, I got round the problem by using BlueStacks. You install BlueStacks on the VM. BlueStacks (at the moment) runs Android 7.1.1, SDK 25. Inside BlueStacks, go to Settings/Preferences and Enable Android Debugger Bridge (adb) following this set of instructions. Then you should be able to run your app on BlueStacks from inside Android Studio. Logcat can see any log statements from BlueStacks.
The alternative (without enabling the debugger bridge) is to locate the .apk file for your app and then open that with BlueStacks APK installer. Logcat still sees the traces.
It's slow on a VM. You also have to set android:testOnly="false" in your XML file
Sorry my bad English.
I installed Android Studio 2.0, and I have problems with the emulator.
When I launch the emulator that I used with Android Studio 1.5.1 appears the windows [A], the emulator is slow
as before but the app works; when in fact I launch a NEW emulator appears to me the window [B], and then appears
no emulator.
WHAT IS HAXM?
How should I do to have a fast emulator?
Regards.
Genymotion makes a pretty good emulator in my opinion. It's way faster than the android studio emulator. Give it a try!
Well don't worry about it. first of all HAXM is a software which makes hardware based virtualization. in simple words it uses your hardware resources to make a virtual device like android device you are talking about.
if you don't have a HAXM software download it and install it and then check if virtualization is enabled or supported in your BIOS settings. press esc or delete whatever the key is to go into bios settings of your computer while computer first starts up. very similar like below.
go to Advanced Bios Features
then look for virtualization if its disabled then enable it otherwise its good to go.
so if you are done with HAXM lets come back to the android studio and start android device manager or AVD and follow the tutorial from android developers page its already answered here. And android emulators are fast now from android studio 2.0 don't worry about it otherwise you can download Genymotion or bluestack
happy coding.
I read that I can run multiple Andy machines in the following link
http://andysupport.s3.amazonaws.com/AndyOSFAQ44v1.pdf
but I cannot open Andy Launcher
I tried to double click HandyAndy's icon in the task bar but it doesn't work
On my windows 8 machine, in the bottom right corner (system tray?) there is an Andy Icon running down by the clock. It might be hidden under an arrow. I right clicked on it and choose "Andy Launcher". You can only run one VM at a time as far as I can figure out. so far.
I can offer:
Emulator as part of the Android SDK
you can download it here: http://developer.android.com/sdk/index.html
To use just open the console /path/to/sdk/tools/android avd
and create your AVD (Android Virtual Device) and run. Or open AVD Manager from Eclipse IDE. But no emulation Bluetooth, OTG, headphones and some other hard parameters. Has a plug-in for Eclipse, easy access via adb
Genymotion
you can download it here: http://www.genymotion.com/
When you create a device from the network pumped his image. APK can be installed by simply dragging them to the window with the virtual machine.
Has a plug-in for Eclipse, easy access via adb and many additional tools (charge control, an accelerometer, API for tests, etc.)
Manymo
Here's an interesting emulator, but slow. No installation required, runs directly in the browser. To use this emulator will require registration.
https://www.manymo.com/emulators
Bluestacks
you can download it here: http://www.bluestacks.com/
It is best to download it from the official site. Works stable than custom build. Easy to install, does not require any additional libraries and files.
Immediately have access to Google Play.
use Genymotion its best way to test your app
or direct run in your phone android device turn on the usb debugging
if you have the memory disk space, You can use Oracle VMware install download a live version of windows, then install andy on each one of your vm machines. I am able to run 10 andy emulators at the same time while using the setting the restrict cpu cores and threads and memory allocations.
I say live os version because in order to run live edition requires 1gb ram, or 2gb for most full desktop OS's
I just setup Android Studio on my PC, which is new launch to develop Android application.
My problem is that, when I try to run my small app in emulator, it take to much time to launch and after then emulator is working slow too.
AVD settings
AVD Name: Glaxy
Device: Glaxy Nexus (4.65", 720x 1280: xhdpi)
Target: Android 4.2.2 - API Level 17
Memory Option: Ram 500, VM Heap 64
Internal Storage: 200MiB
I have good window pc: Intel Core 2 Duo 2.93Ghz and Ram is 3gb
I am new in Android development and java.
The Best Solution is to use Android Emulator with Intel Virtualization Technology.
Now if your system have a Processor that have a feature called as Intel Virtualization Technology, then Intel X86 images will be huge benefit for you. because it supports Intel® Hardware Accelerated Execution Manager (Intel® HAXM).
To check that your processor support HAXM or not : Click Here
You need to manually install the Intel HAXM in your system. Follow these steps for that.
First of all go to - adt -> extras -> intel -> Hardware_Accelerated_Execution_Manager
Make sure that Intel Virtualization is enabled from BIOS Settings.
Now install Intel HAXM in your system and select amount of memory(i prefer to set it as default value).
After installation create new Android Virtual Device (AVD) which should have a Target of API Level xx
Now set the CPU/ABI as Intel Atom(x86).
If you are on Windows then do not set RAM value more than 768 MB while setting up an emulator.
Run the emulator. It will be blazing fast then ordinary one.
Hope it will be helpful for you. :) Thanks.
Just edit the AVD settings as below,
Enable snapshot options and please use INTEL HAXM software for speedup.just visit https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm and download...
I tried all the suggested remedies and none had any impact. The Android Studio emulator experience was simply unusable with my setup (Windows 10, AndroidStudio 3.5, Quadcore 3.2 Ghz, 32GB with SSD drive).
I tried Updating Studio, Installing Intel HAXM, Changing the memory settings via SDK, using an actual device, excluding the various folders from in the Windows Anti-virus among other things.
The solution that made it work like a breeze was to exclude the Android Debug Bridge (adb.exe) "as a process" from the Windows Security / Virus Protection. You can either do it yourself or read the details below to know how to do it.
I suggest verifying the severity of the speed issue yourself. The same will be used to verify the difference immediately after you apply the remedy. Running the options from within Android Studio just makes it more complex.
Steps to check the issue:
Get the path for your Android SDK Tools. You can find it from SDK Manager -> Appearance and Behavior -> System Settings -> Android SDK.
Open a command prompt or terminal window. You can do right click on Windows (Start) Icon -> Run and execute "cmd". This should give you a windows command prompt or terminal window.
In the terminal window, change your drive and path to your Android SDK folder using the CD command. Now change to the sub-folder Platform-tools.
You will find the Android Debug Bridge (adb.exe) in this folder. This plays a very crucial role in operating the emulator as well as the actual device.
In the terminal window, execute the adb.exe tool with the command adb. It should instantly return back with the help parameters for adb.
Now execute adb.exe with a command like - adb devices. This should simply stall and take several seconds to come back with the information even if you have no devices or emulator running. In my setup it took almost 30 seconds. This is the issue.
Anything you do with the emulator goes via adb and gets stuck here. Once the remedy is applied, it should execute the adb devices command as instantly as the simple adb command without any parameter.
Steps to remedy:
Go to Windows "Virus and Threat Protection" setting. There are several ways to reach it. You can use Right Click on Windows (Start) Icon and choose Settings. Choose Update & Security, then Windows Security, then Virus and Threat Protection.
You will find the option Virus and Threat Protection Settings. Select it. You will find several options, look for Exclusions. Select the option Add or remove exclusions. This will take you to the list of Files, Folders, Processes which are presently excluded by the windows anti-virus. It may be empty or may have some data.
Select "+ Add an Exclusion". You will find 4 options - File, Folder, File Type and Process. This is critical. Please choose Process.
In the "Enter Process Name" input box type in the name adb.exe. Please dont forget to type in the extension, just putting adb will not work. Accept the input with "Add" button.
You are done. Now goto the command prompt again and follow the same steps you did earlier to check the issue. Hopefully you will be pleasantly surprised and your entire Android Studio emulator experience should become seamless.
Note that the steps may slightly vary depending upon your version of Windows, Android Studio and SDK tools however it should still apply.
The new Android Studio incorporates very significant performance improvements for the AVDs (emulated devices).
But when you initially install the Android Studio (or, when you update to a new version, such as Android Studio 2.0, which was recently released), the most important performance feature (at least if running on a Windows PC) is turned off by default. This is the HAXM emulator accelerator.
Open the Android SDK from the studio by selecting its icon from the top of the display (near the right side of the icons there), then select the SDKTools tab, and then check the box for the Intel x86 Emulator Accelerator (HAXM installer), click OK. Follow instructions to install the accelerator.
Be sure to completely exit Android Studio after installing, and then go to your SDK folder (C:\users\username\AppData\Local\extras\intel\Hardware_Accelerated_Execution_Manager, if you accepted the defaults). In this directory Go to extras\intel\Hardware_Accelerated_Execution_Manager and run the file named "intelhaxm-android.exe".
Then, re-enter the Studio, before running the AVD again.
Also, I found that when I updated from Android Studio 1.5 to version 2.0, I had to create entirely new AVDs, because all of my old ones ran so slowly as to be unusable (e.g., they were still booting up after five minutes - I never got one to completely boot). As soon as I created new ones, they ran quite well.
Check this: Why is the Android emulator so slow? How can we speed up the Android emulator?
Android Emulator is very slow on most computers, on that post you can read some suggestions to improve performance of emulator, or use android_x86 virtual machine
As #Xavi mentioned, Android Emulator is normally slow and lags a lot. Either test your app on an actual device or use an alternative emulator such as BlueStack or Android-X86.
Another tip for using emulator is to not close if you ain't done testing your application. Just leave it open. In this case you skip the time it takes to launch.
Use x86 images and download "Intel Hardware Accelerated Execution Manager" from the sdk manager.
See here how to enable it: http://developer.android.com/tools/devices/emulator.html#accel-vm
Your emulator will be super fast!
The emulator is much much faster when running on Linux. In Ubuntu 13.04, it launches within 10 seconds, and it runs nearly as smoothly as on a physical device. I haven't been able to reproduce the performance on Windows.
EDIT:
Actually, after the first boot, when using the Atom arch. and GPU acceleration, the Windows emulator runs nearly as well as in Linux.
Try increasing your ram of intel HAXM by reinstalling it..
Worked for me..
In my pc HAXM setup's location was here:
C-Users-Pc's_name-AppData-Local-Android-sdk-extras-intel-Hardware_Accelerated_Execution_Manager
Check this list:
install Intel HAXM
just use x86 AVD
use small size screen
I tend to load AVD through snapshot which can be setup in the AVD Manager > Choose AVD > Details... > Checking Emulator Options: Snapshot, and then to run the AVD, Select AVD in AVD Manager > Start... > Select Save To Snapshot and Launch from Snapshot. The first time, ensure that save to snapshot is chosen, as no snapshot exists to launch. The next time onwards choose launch from snapshot.
Slightly apprehensive to suggest this as well, but I have noticed a peculiar behavior when loading and running AVD. When I have the laptop battery being charged on my Lenovo laptop - 64 bit Windows 7, 4GB, 2.5GHz machine, the emulator loads and runs slightly faster and also lags less. I wonder if it is the configuration on my laptop to slow down high computational processes. Would be nice to know if someone else has noticed this behavior? Unplug the charger when the AVD is loaded and see if the AVD slows down.
A quick fix if using Android Studio (or Eclipse) is to disable the boot animation.
1) Select Run > Edit Configurations
2) Android Application > YOURAPP
3) Select the "Emulator" tab and check the "Disable boot animation"
This is will stop the "ANDROID" image from loading and boot directly to the lock screen, then keep your the emulator open. Also, to avoid problems, don't rotate the device before launch (Cmnd + Ctrl + F11), and don't try to run the app more than once during installation.
Android Development Tools (ADT) 9.0.0 (or later) has a feature that allows you to save state of the AVD (emulator), and you can start your emulator instantly. You have to enable this feature while creating a new AVD or you can just create it later by editing the AVD.
Also I have increased the Device RAM Size to 1024 which results in a very fast emulator.
Refer the given below screenshots for more information.
Creating a new AVD with the save snapshot feature.
Launching the emulator from the snapshot.
And for speeding up your emulator you can refer to
Speed up your Android Emulator!:
Try using another android virtual device. You can create one by adding a new device by going to the AVD Manager. Select the screen size 3'2 and API-10 (gingerbread).
This worked for me, and it is super-fast now.
P.S.- My laptop used to take forever to load the emulator, and It never got started due to insufficient memory(4.2). I used to get restart again and again. This solved my problem.
Google Launches Android Studio 2.0 With Improved Android Emulator And New Instant Run Feature
New Features in Android Studio 2.0 :
1.Instant Run: Faster Build & Deploy
You can quickly see your changes running on your device or emulator.
Enable Instant Run follow this steps:
1.open Settings/Preferences
2.go to Build, Execution, Deployment
3.Instant Run. Click on Enable Instant
Please see this video of Instant Run --> Instant Run
2.GPU Profiler
For developers who build graphics-intensive apps and games, the Studio now also includes a new GPU profiler. This will allow developers to see exactly what’s happening every time the screen draws a new image to trace performance issues.
click here for more details about the GPU Profiler tool
Getting Started Guide for Android Emulator Preview
For more detail about android 2.0 Biggest and best update of 2015 you can see very good article Author by #nuuneoi :
First Look at Android Emulator 2.0, the biggest and the best update yet in years
In my case, the problem was coming from the execution of WinSAT.exe (located in System32 folder). I disabled it and issue solved.
To turn it off:
Start > Task Scheduler (taskschd.msc)
Find Task Scheduler (Local)
Task Scheduler Library
Microsoft > Windows > Maintenance
Right click WinSAT
Select disable.
The Reference
Also, suppress it from Task Manager or simply reboot your machine.
Point: In this situation (when the problem comes from WinSAT) emulator works (with poor performance) when you use Software - GLES 2.0 and works with very very poor performance when you use Hardware - GLES 2.0.
Aside from what everyone has already said about HAXM and other configuration settings as solutions for this problem, my solution had nothing to do with software configuration or processor limitations.
I setup Android studio on an older HDD and I had Visual Studio running an android emulator on an SSD. My bottleneck was the old HDD - the SSD I had resulted in more speed.
The solution - albeit not the best for you - is to look in installing an SSD. This is not a very feasible solution in 90% of the cases but for me the root cause was linked to my hardware - not my software config.
Hope this helps another person facing a similar problem!
This worked for me. My size on disk was just too high for the emulator to run correctly. Wiping the data took it from 4.9 GB to 2.9 GB.
Click on the AVD manager at the top right and it will pull up a screen with all your devices. In row with your device the very last icon will be a drop down arrow, click it. Click 'Wipe Data' then 'Cold Boot'
For those who enabled HAXM and the emulator still works slow here is what you should do:
If Avast antivirus is running on your computer, it is most likely the culprit.
as per HAXM Release_Notes.txt (Version 7.5.2):
On Windows, Avast Antivirus may interfere with HAXM and cause Android Emulator or QEMU to run very slowly. A workaround is to uncheck "Use nested virtualization where available" in Avast Settings > Troubleshooting.
So open your Avast dashboard > Menu > Settings > Troubleshooting and disable "Enable hardware-assisted virtualization"
Give a higher priority to your emulator's process in the Task Manager:
Locate your emulator's process in the Task Manager > Details tab:
Right-click on it and Set Priority -> Above normal
Sorry that the screenshot is not in English but you got the point, right?
That helped me significantly! I hope it will help you as well.
Also, one thing as per the Release Notes:
On Windows 8, 8.1 and 10, it is recommended to disable Hyper-V from Windows Features in order for the HAXM driver to properly function.
In my case, I didn't have any "Hyper-V" feature on my Windows 8.1 but you probably should try it, just in case. To locate and disable that feature see this article: https://support.bluestacks.com/hc/en-us/articles/115004254383-How-do-I-disable-Hyper-V-on-Windows-
This is probably because incomplete files in your sdk . Sometimes firewall of ur office or somewhere blocks it and hence error message comes saying peer not authenticated I was facing the same problem but after downloading all the files by getting firewall access
My emulator is working properly and much faster than before