21

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).

Android Studio Version Info

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.

starting...

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?

turn off Hyper-V

raddevus
  • 8,142
  • 7
  • 66
  • 87

4 Answers4

13

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.

Tom Mettam
  • 2,903
  • 1
  • 27
  • 38
  • You are correct and that was true even with Studio 1.5.1 for x86 emulation images but the ARM based devices still ran on VMs because HAXM was only for x86. Maybe ARM devices are unsupported now too. – raddevus Apr 19 '16 at 21:32
  • The emulator is always x86 – Tom Mettam Apr 19 '16 at 21:50
  • And yet, if you examine the last image in my post, you can clearly see I have chosen to download the ARM versions of the Android OS images. :) The emulator is x86 but the image that runs on the x86 machine can be ARM or x86. – raddevus Apr 20 '16 at 11:56
  • That's what I said.. the emulator is always x86. The ARM layer is abstracted and fully emulated. But the emulator itself is x86, and it uses HAXM. – Tom Mettam Apr 20 '16 at 12:58
  • And yet, you are off on a tangent. The original question says that I can run the Emulator on a VM under Android Studio 1.5.1 running an ARM image. And now I cannot run the emulator at all under Android Studio 2.x -- not even an ARM image seems to run. That was because under 1.5.1 HAXM only ran for x86 images -- not ARM. Do you believe that HAXM runs for both now? Do you have evidence that HAXM runs for ARM images on 2.x? Because HAXM is based upon x86 and that would seem odd. – raddevus Apr 20 '16 at 14:28
  • 4
    Yes, that's exactly what I said. The emulator is always x86 now, and always uses HAXM. So the answer is "no", as per my answer. The ARM emulation is done at a higher level under software emulation (actually, instruction translation), above the x86 layer. – Tom Mettam Apr 20 '16 at 15:09
  • NOTE: With Version 2.1 of Android Studio I have successfully run an ARM-based AVD (Android Virtual Device) on my VMWare VM. See my answer below. – raddevus May 13 '16 at 16:53
  • 7
    A bit of an odd question I guess, is it possible to run the AVD on the host machine and see it from the VM? – Vlad B Feb 06 '17 at 12:30
  • 1
    @vlad-b have you found answer for your question? – mesut Jul 07 '18 at 17:28
  • 1
    @VladB To connect to remote emulator(s) you can use the command `adb connect ip-address-of-emulator-host:5555` in the virtual machine (5555 is the default adb debug port of an emulator). Doing so will make the remote emulator appear in the connected device list just like a directly connected device or local emulator. Keep in mind though that a lot of emulators listen to local connections only, so the connection might not always work. You can bypass this limitation by setting up a port redirect. – Leon Lucardie Mar 09 '20 at 17:17
13

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

  1. Go to location where you've installed the Android SDKs (in my case it is at %appdata%\Android2\SDK\
  2. If you are in the right place you should see a directory structure and directories like the ones shown in the first image below.

sdk dir

  1. Start the AVD.exe by double-clicking it.

You will see a window like the one in the image below avd manager

  1. 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).

  2. Also, you cannot start these images from AVD that launches from Android Studio 2.x

  3. 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.

enter image description here

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: android 7 arm

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.

android 7 running

raddevus
  • 8,142
  • 7
  • 66
  • 87
  • 1
    At step3 in Tab Android Virtual Devices, I have no device in the list. How to get to an ARM Based Image device ? – mcfly soft Jan 21 '17 at 10:37
  • In Step 2, take a look at the first image of my file system. There is an SDK Manager.exe in there. Run that app first and choose one of the ARM based images. it will download it and install the image, and then it will show up in the list the next time you start AVD Manager. – raddevus Jan 21 '17 at 16:21
  • Thanks a lot for helping. I finally could create an AVD with Android7.0 ARM (armeabi-v7a) API24 and I started the AVD. Emulator started, but after 10 mins its still only a black window. In the log window I can see one Warning : Missing WGL extension WGL_ARB_make_current_read . Any help ? – mcfly soft Jan 21 '17 at 17:58
  • First time start of emulator is always a pain. I'm not sure about Android 7 and requirements if it'll run on VM emulator. Maybe try earlier Android version and see if that starts. Also, others have reported the problem you're seeing at : http://stackoverflow.com/questions/11407501/android-emulator-could-not-get-wglgetextensionsstringarb-error There may be something you can try there, but doesn't seem to be a definitive answer. Sometimes, just stopping the emulator and starting it again can fix this. – raddevus Jan 22 '17 at 16:36
  • 2
    I can confirm, that for older Versions it works. But for Android 7 not. – mcfly soft Jan 23 '17 at 14:29
  • @mcflysoft Good to know. Thanks for trying it out. I believe my original SO post was written before Android 7 released so I hadn't ever tried it. – raddevus Jan 23 '17 at 15:06
  • @mcflysoft I've been working with the android emulator and I was able to get Android 7 running on my 2012 R2 VM. I'll edit this answer to show screenshots for what I did. The main thing is it seems that you have to choose an ARM OS image that does _not_ include the google APIs. – raddevus Jan 27 '17 at 20:50
  • @raddevus Hello, is this still working for **Android Studio 3.1**? Most of the procedure you mention in your answer no longer apply. I cannot make it play in a VM. I get black screen and a sound error: https://stackoverflow.com/questions/51330309/android-studio-emulator-audio-error – BugShotGG Jul 28 '18 at 18:51
  • @BugShotGG I just started the emulator and ran it on my VM on Studio 3.1.3 so it does still work, but it is _very_ slow, especially compared to the x86 HAXM images. Keep in mind you can only run the ARM images on a VM and I've never gotten the images with Google Play working on a VM. As a point of reference here is a snapshot of the exact Android image I got it working on : https://i.stack.imgur.com/e0zxM.png – raddevus Jul 30 '18 at 12:45
  • @raddevus I dont understand what is wrong in my case. Could you check the thread that I have opened about the problem? The thread link is in my previous comment. Thanks in advance! – BugShotGG Jul 30 '18 at 16:58
  • @yams Actually, it does still work. I use it every day on my VM. It's running on my VM right now. You have to run a non-x86 image. You have to run an ARM image that does not contain the Google play services. – raddevus Feb 20 '20 at 12:49
  • not for HAXM. and most clients I work with only work with X86... So not really – yams Feb 21 '20 at 17:55
2

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.

user3673952
  • 698
  • 10
  • 30
0

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

Pam
  • 1,146
  • 1
  • 14
  • 18