Critical Error Running Android Emulator

Discussions related to using VirtualBox on Windows hosts.
Post Reply
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Critical Error Running Android Emulator

Post by claytoncarney »

VBox.log:
VBox.zip
log file
(123 KiB) Downloaded 9 times
Attempted to attach VBox.png as requested, but file exceeds 128 KiB limit (and compression does not help).

Encountered critical error attempting to run Android Emulator.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Critical Error Running Android Emulator

Post by scottgus1 »

claytoncarney wrote:Critical Error Running Android Emulator
the log wrote:00:00:03.050182 Guest OS type: 'Ubuntu_64'
00:00:03.053417 File system of 'V:\VMs\ubuntu-20-aosp\ubuntu-20-aosp.vdi' is ntfs
Are you sure you posted the correct log?

The log did show a guru meditation on VERR_EM_INTERNAL_ERROR, which a long time ago was solved by dsabling Nested Paging on thehost or by enabling YT-x. Your host has Nested Paging enabled, and VT-x is enabled. I would not disable Nested Paging for now, but we'll need a guru to come along to show us the path.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Critical Error Running Android Emulator

Post by mpack »

I would try increasing the graphics RAM to something useful. You must be getting an invalid settings error for the current 16MB, especially after you also enabled 3D acceleration.

I see GAs loading successfully, so this is definitely not an Android guest.

The VM settings are all wrong for an Android guest, but perhaps an Android emulator was run inside the VM. I don't know why you'd do that, but note that nested VMs are only supported when VirtualBox is the inner and outer hypervisor.
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Re: Critical Error Running Android Emulator

Post by claytoncarney »

I'm an AOSP newbie, but AFAIK, the emulator requires virtualization.

If I turn Settings>System>Processor>Enable Nested VT-x/AMD-V off, the emulator won't start:

Code: Select all

clayton@ubuntu-20-aosp:~/aosp$ emulator
emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
CPU acceleration status: KVM requires a CPU that supports vmx or svm
More info on configuring VM acceleration on Linux:
https://developer.android.com/studio/run/emulator-acceleration#vm-linux
General information on acceleration: https://developer.android.com/studio/run/emulator-acceleration.
I've attached another log to confirm. Any thing else I should provide?
Attachments
log 2.zip
(123.06 KiB) Downloaded 7 times
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Re: Critical Error Running Android Emulator

Post by claytoncarney »

OK, I increased video memory to 128 MB (log 3.zip).

Then I disabled 3D acceleration (log4.zip).
Attachments
log 4.zip
(79.8 KiB) Downloaded 54 times
log 3.zip
(180.02 KiB) Downloaded 5 times
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Critical Error Running Android Emulator

Post by scottgus1 »

claytoncarney wrote:clayton@ubuntu-20-aosp:~/aosp$ emulator
It appears you are running this "emulator" inside the VM, which is behaving as if it wants to be nested virtualization:
claytoncarney wrote:emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
CPU acceleration status: KVM requires a CPU that supports vmx or svm
Your CPU seems to be OK for this:
00:00:03.920098 VMX - Virtual-Machine Extensions = 1 (1)
00:00:03.920108 Ept - Extended Page Tables = 0 (1)
00:00:03.920110 UnrestrictedGuest - Unrestricted guest = 0 (1)
00:00:03.920112 VmcsShadowing - VMCS shadowing = 0 (1)
Settings>System>Processor>Enable Nested VT-x/AMD-V needs to be on at least.

The third log shows the 128MB VRAM and the fourth shows 3D off, both still guru-meditate. I am not certain what else needs to be checked. It could be that this emulator needs to run in an OS on the bare metal, not in a VM.
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Re: Critical Error Running Android Emulator

Post by claytoncarney »

I was beginning to suspect that. I found this post (https://stackoverflow.com/questions/367 ... -on-vmware), which states:
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.
Does this appear to be correct relative to VBox?
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Critical Error Running Android Emulator

Post by fth0 »

According to the VirtualBox User Manual (9.33. Nested Virtualization) and my own experiments, VirtualBox VMs and QEMU/KVM VMs can each run nested inside a VirtualBox VM.

The Android Emulator uses Intel HAXM on Windows and macOS, but QEMU/KVM on Linux, so the documented requirements are fulfilled inside a VirtualBox Linux VM in theory. I don't know what the emulator command really tests in practice, though. Can you give short instructions what to install and execute to reproduce the behavior?

Regarding the Guru Meditation: 1 of the 4 vCPUs is executing the nested VM (VMX_EXIT_VMRESUME) and an "external" interrupt occurs (VMX_EXIT_EXT_INT), which leads to an internal error (VERR_EM_INTERNAL_ERROR). This sequence of events exceeds my current knowledge of the inner workings of the VirtualBox hypervisor core.
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Re: Critical Error Running Android Emulator

Post by claytoncarney »

I basically followed the 'Building AVD images' instructions here: https://source.android.com/setup/create/avd

The deviations were:
* including '-b android-11.0.0_r29' for the 'repo init' command
* including '-c' for 'repo sync' command (and -j4 instead of -j24, since I only have 4 cores).

I chose 'lunch sdk_phone_x86_64' as the target. 'make' again used '-j4'.

In the process of dual boot setup. I plan to start over with bare metal Ubuntu.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Critical Error Running Android Emulator

Post by mpack »

Why would you nest an Android VM inside a Linux VM? Why not create an Android VM on the Windows host and avoid all these unnecessary nesting problems?

I suspect that at the root of this is that you have misunderstood the requirements of the Android emulator. You have seen an instruction saying that the emulator requires that the PC support virtualization, referring to a hardware feature of most modern CPUs. But you've taken that to mean that you must run it inside another VM (which is a software client of the hardware feature), which is not the case.

If you want an Android emulator that works well on Windows hosts then go download the free version of BlueStacks.
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Re: Critical Error Running Android Emulator

Post by claytoncarney »

The docs state that Android development is not supported on Windows; only on Linux and Mac. Refer to the 'OS' section here: https://source.android.com/setup/build/requirements.

I have only one computer running Windows. That is why I was using a VM.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Critical Error Running Android Emulator

Post by mpack »

Hmm. I installed Android Studio on my Windows 10 PC just last week. It seems to run just fine.

The link you give seems to be a source code archive for the Android OS itself, not development for Android, and not an Android emulator. But it was only a quick glance so I could be wrong.
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Re: Critical Error Running Android Emulator

Post by claytoncarney »

To clarify, I'm working on custom ROMs. AFAIK, the toolchain to do that is only available on Linux and Mac, not Windows. Since I don't have any spare Android devices I can flash, my only option is to use the emulator.
claytoncarney
Posts: 46
Joined: 21. Oct 2011, 21:01
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Ubuntu 20

Re: Critical Error Running Android Emulator

Post by claytoncarney »

Completed Windows/Ubuntu dual boot setup. Performed the same environment setup and build steps on bare metal Ubuntu. Emulator works there without issue. So it appears that, for some reason, the emulator won't run in a VM.
Post Reply