Android emulator fails to start when used with tcpdump-option - android

When I run an AVD from the Terminal on Ubuntu 14.04, the following command is working without problems:
my_name#host:~$ emulator -avd my_avd
But when I want to use tcpdump to capture the network-traffic, the emulator fails to start:
my_name#host:~$ emulator -avd my_avd -tcpdump ~/test.cap
qemu-system-i386: -tcpdump: invalid option
I have no problems running the emulator with tcpdump on Windows, but on Ubuntu and Debian it refuses to work. Might this be a Bug or am I missing something? The same problem occurrs when I want to use the option -timezone Europe/Berlin. In contrast, the option -dns-option 8.8.8.8 is working fine. The problem occurrs for every AVD.
Android SDK:
SDK Tools 25.1.1
Platform-Tools 23.1
Build-Tools 23.0.3
Android 6.0 SDK Platform Revision 3
Android 6.0 (Intel x86 Atom Image 32/64 Bit Revision 8 and ARM EABI v7a Image Revision 3)
Virtualization (KVM) is enabled on Intel Core 2 Duo. Oracle JDK 8 is installed.

The same behavior occurred on my Mac, the solution seems to be to add -engine classic to your command line call. So it reads:
my_name#host:~$ emulator -avd my_avd -tcpdump ~/test.cap -engine classic
Credits go to #Interix for posting this here

According to your emulator, -tcpdump is an invalid option. Check emulator -? or man emulator for the syntax. However, I'd be surprised if this would normally work at all - I haven't seen tcpdump integrated with anything as an argument by itself (though I'm sure it's not impossible).
Normally I'd expect to use tcpdump as a command by itself. Depending what tools you have installed, I'd run up the emulator, check what ports it's running, and run tcpdump against its port range separately if you're looking for incoming traffic. If it's outgoing, use tcpdump to trace the traffic to the destination you're going to use.

Related

Android Studio Emulator is not working on Windows 11 when WSL2 is installed

Setup:
Windows 11 Home 21H2 22000.132
AMD Ryzen 5900X
WSL2
Android studio lastest build (also tried with latest beta)
Problem:
As soon as I install WSL2, the emulator stops working. It's giving the following error message:
C:\Users\gusta\AppData\Local\Android\Sdk\emulator>emulator.exe -avd Android_TV_1080p_API_300
emulator: Android emulator version 30.8.4.0 (build_id 7600983) (CL:N/A)
handleCpuAcceleration: feature check for hvf
added library vulkan-1.dll
Failed to open /qemu.conf, err: 2
C:\Users\gusta\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
C:\Users\gusta\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: failed to initialize WHPX: Invalid argument
Using WSL2 at the same time as the android emulator was working before on an Intel i7 4770k processor, but stopped working after a processor upgrade to a AMD Ryzen 5900x and fresh install of Windows 11.
For clarification: I'm not trying to run the emulator from WSL2, I'm trying to run it from Android Studio. When trying to start it from Android Studio it never launches, when trying to run it from the Windows Command Line I get the above error.
The "Failed to open /qemu.conf" is possible to solve by creating that file manually, as explained by this answer. That however doesn't fix the two later errors with WHPX.
I've followed the official instructions on this page (Following the AMD with Hyper-V option WHPX). I think the problem has to do with Hyper-V running which WSL2 is using if I'm not misstaken. But according to the above link it should be possible to run the emulator at the same time as Hyper-V using WHPX. I've also tried using the Android Emulator Hypervisor Driver for AMD processors, which is giving me the exact same result.
Activated Windows features:
Thankful for any help, and please tell me if I need to add more information
Newer Answer
I found and tested in shorter toggle mechanism.
The configuration for Windows Feature:
Windows Subsystem for Linux is installed.
Windows Hypervisor Platform is installed.
Hyper-V is installed.
If you need the Emulator, you only need to turn off Hypervisor + Restart. Run: bcdedit /set hypervisorlaunchtype off
If you need the Docker back, you can run the hypervisor hence disabling Emulator. Run: bcdedit /set hypervisorlaunchtype auto
You need to restart after setting Hypervisor
You cannot run both at the same time. Another forum worth checking in How about running docker? in my older answer below.
Older Answer
I think I solved this issue, tested to run from CMD / Android Studio and ran perfectly as before installing WSL. There are several step we go:
Configuring Windows Feature:
Removed Windows Subsystem for Linux
Removed Windows Hypervisor Platform
Removed Hyper-V
Here is my current setup:
Reverting AVD setup
I know after removing there are some odds because the AVD still get the same error as before and expected to get into WSL. I stumbled and found something when ran:
C:\Users\[NAME]\AppData\Local\Android\Sdk\emulator\emulator-check.exe accel
That command will check the current accel. It explains that the Hypervisor need to be set off and give specific help:
run bcdedit /set hypervisorlaunchtype off.
After running the bcdedit, I restarted and all is reverted. Now I can run emulator both from CMD and Android Studio perfectly.
How about running docker?
Sad truth, yeah you cannot run both pararel. There are several workaround in this forum:
How can I run both Docker and Android Studio Emulator on Windows?
Several option ranging from changing emulator, add & remove docker when in need using above step, created nested vm, etc. My personal choice right now is using another Emulator for the time being and removed docker for the latter.
I finally got this working using this fix (answer number 48). Seems like a valid workaround until windows fixes this issue. I downloaded the compiled version for windows and moved it to my emulator path C:\Users\<username>\AppData\Local\Android\Sdk\emulator. Seems to be versions available for linux and mac as well but I haven't tested those.
This issue is tracked by Google bug https://issuetracker.google.com/issues/202188690
This problem only occurs with AMD processors, I have two systems both with WSL2 and Docker running on the latest Windows 11 (Insider Beta) build. One with an AMD Ryzen 5950 and one with an Intel i7-8086K.
On the Intel system the emulator runs fine with hardware acceleration together with WSL2 and Docker.
On the AMD I run into the same error when running the emulator with hardware acceleration. In the Windows 10 Insider builds before Windows 11 it still worked.
A very similar problem was introduced before in Windows 10 build 10.0.21292
and later fixed in build 21327. (https://github.com/microsoft/WSL/issues/6471) But this problem affected both Intel and AMD.
I haven't tried to turn off the AMD fTPM yet, as this is the only other change apart from updating Windows 10 Insider (dev ring) to Windows 11.
The Android Emulator Hypervisor Driver for AMD processors only works when the Windows Hypervisor is disabled, it's not used for WHPX.
The Windows Feedback is full of reports of this problem, please upvote them.
Android Studio emulator doesn't support run Hyper-V on Windows 11, we can disable Hyper-V to run but if we do that applications which require Hyper-V to run like WSL2, Docker then fail to run.
While waiting Google update Android Studio emulator support Hyper-V we have a workaround solution to run both by using another emulator which support Hyper-V like Bluestack 5 version "Nougat 64 bit (Supports Hyper-V)" at the link below
https://www.bluestacks.com/download.html
If you did all of those steps and still you are facing that emulator termination issue, then please upgrade or download your graphic card drivers and install it. After I installing Windows 11 this issue happened to my android studio emulator. Lot of steps I followed but nothing work. after that I checked my Graphic card drivers and install it. Now emulator working fine...

Running android emulator with Azure windows 10

I am trying to run an android emulator on an azure VM running windows, Windows 10 Pro version 1809 - But I am getting the following error message running the android emulator:
C:\Program Files (x86)\Android\android-sdk\emulator>emulator -AVD androidemulatorapi28
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure the Windows Hypervisor Platform (WHPX) is properly installed and usable.
CPU acceleration status: HAXM is not installed on this machine
The hyper-v is enabled:
And Windows Hypervisor Platform as well:
The size of the VM is D2_v3 and Dv3 - series is supposed to support Nested Virtualization. Here, here and here are claims about it being so and that android emulator functions. And as I far as I have understood:
...is part of Dv3 series.
What could be the problem?
I am able to run an Ubuntu VM in Hyper-V of the Azure Windows VM.
Disabling Hyper-V and Windows Hypervisor Platform, installing HAXM and running I get this error:
According to the writer of this medium article and this StackOverflow discussion - A special custom implementation of OpenGL is necessary - because the particular azure VM size doesn't come with a GPU. However, following the steps of the article I get another type of crash - when using the Mesa3D+LLvmpip version of opengl32.dll from the authors Github repo, replacing the OpenGL file in system32 and running the android emulator:
I found there was a gihub repo - distributing Mesa3D and LLvmpip - downloading mesa3d-19.1.3-release-mingw.exe and running the cmd file:
There is the following message in cmd:
This deployment utility targets systems without working GPUs and any use case
where hardware-accelerated OpenGL is not available. This mainly covers
virtual machines in cloud environments and RDP connections. It can be
used to replace Microsoft Windows inbox OpenGL 1.1 software render
driver with Mesa3D soft pipe, llvmpipe or SWR driver.
...which seems to be a fit for the driver rendering problem.
I was able to git rid of all cmd warnings and error by-avd myandroidemulatorapi28, and any with of following two flags -gpu angle_indirect or -gpu swiftshader_indirect. And set QEMU_AUDIO_DRV=none before running it. The GUI message about the driving issue still comes up and there is a black screen.
According to the owner of the mesa-dist-win GitHub repo - he could reproduce the GUI message diver complaint and still run the emulator successfully - when imitating the state of a VM with his machine.
Note: This is not a solution, this is for sharing details of what I learned after trying out around 10-20 ways:
To enable virtualization in azure VDI, you need to enable Hyper-V feature.
After that you can see in your task manager->Performance that the virtualization is set to true.
If not, try enabling it from command prompt.
bcdedit /set hypervisorlaunchtype auto
After that virtualization is enabled.
Now, you won't be able to install Intel HAXM, as there is a race condition between Hyper-V and Intel HAXM for virtualization.
So, Without Intel HAXM, AVD won't run.
Without Enabling Virtualization with Hyper-V, there will be just black screen in AVD, and it won't boot.
So, I believe there is no solution to this problem until now, I have search everything on google, stackoverflow. If someone finds a solution, please post it over here.
Im facing the same issue with you using Win10 or Windows Server 2019 for DV3 and EV3 series. But I got it working on ubuntu if you are open for that option. No hyper v or haxm required, it is using KVM
Just go to the link "https://github.com/intel/haxm".
Scroll down to find "Downloads".
Download the "haxm-windows_v7_7_1.zip" for windows & haxm-macosx_v7_7_1.zip for macoxs.
Install the package and it will solve the issue.
They is another android emulator that is working
https://www.sanganakauthority.com/2020/04/run-android-emulator-and-android-studio.html

Intel HAXM under a guest OS (Windows 10) running on Linux (KVM) crashes in Android emulator

Need help about Intel HAX which crashes under Windows 10 when running Windows 10 as a guest OS in a VM.
Some background information:
Hypervisor: KVM (virt-manager on ubuntu 16.10)
Guest operating system: Windows 10
Nested virtualization allowed
VT-X in Bios set
Intel HAX installed (latest version)
Android Studio (Version 6 as image for the Android emulator)
Problem:
When I run Android Studio and use Intel (x86) boot option to show up Android Emulator, Windows crashes completely. The error is a problem with a sys file of Intel HAX. Unfortunately I expected some wrong behavior of the Windows 10 running as VM with some nested virtualization components. In arm-mode I can start up the Android emulator but it's very slow. Is there a solution to use Google Intel (x86) Android image anyway? Some special key to start the emulator with?
The emulator is not really intended to be run in this configuration. You can try several things:
Run the emulator from the cmd line with the -no-accel flag.
Uninstall HAXM.
Note that performance will not be very good.
If possible try to run the emulator in the linux host, or under a linux guest.

Android Studio emulator doesn't work

I have just installed Android studio but when I try to run my app I get the following error message
emulator: ERROR: This AVD's configuration is missing a kernel file!!
emulator: ERROR: ANDROID_SDK_ROOT is undefined
I am using Ubuntu 12.04 LTS and I have an intel B960 ( I have read that this cpu doesn't support virtualization ).
I read many answers ( on stackoverflow too ), but it doesn't work:
I checked that $ANDROID_HOME/Sdk/system-images/android-MNC/default/armeabi-v7a exists and is not empty.
I installed ARM EABI v7a from the AVD Manager.
I installed KVM by using:
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
But then I get this:
# kvm-ok
INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used
what other do I have to try ?
It looks like your emulator is trying to use a version of the SDK that you don't have installed. You could either change the SDK of the AVD, create a new AVD with a different SDK, or install the appropriate SDK, and make sure that your environment variable is set correctly.
But frankly, I wouldn't bother. Get the Genymotion emulator instead. The difference between it and the built-in emulator can not be overstated. The free version has everything you need for basic tests. There are other emulators available, and I've heard they're all better than Android Studio's, but I only have personal experience with Genymotion. I ran a test where I started the Android Emulator first, and then the Genymotion emulator, and I had booted the Genymotion emulator and completed my test suite long before the Android Emulator finished booting.

Android Studio - Virtual device launch fails

You might have seen a hundred questions already by the same title so let me just tell you why mine is different:
Here's the error:
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: HAX kernel module is not installed!
I've already installed HAXM installer from the sdk manager
When I actually go to install HAXM, it says that my computer doesn't support virtualization
True that. I have Intel Pentium E2180
My hyper -v is already disabled
My BIOS doesn't have an "enable virtualization" option (which is obvious because my processor doesn't support it)
Since all the solutions on stack overflow revolve around the above mentioned points I decided to post this quesiton as all the mentioned solutions didn't work, which I think is precisely because of me not having a supported processor, which brings me to my question:
Can I still somehow run a virtual device to test my apps? I have a Nexus 7 tab, but I still think testing on a virtual device is more convenient and also I can test more devices if they're virtual..
P.S. I'm running Windows 10 (technical preview) Build 9926.
In this case you can download and use ARM images that do not need hardware virtualization instead of using x86 system images. Need to tell you that ARM images will be very slow compared to x86 images.
You can download ARM image of respective APIs by selecting this option.
In order to run the emulator you have to use ARM image, because your PC doesn't support HAXM
Create a new AVD(Android Virtual Device) and on creation select image that uses ARM(such as armeabi-v7) so it will be emulated on your PC.
Here's picture of image selection
If you don't have any arm images installed, you can download one from SDK manager
Or else you can use Genymotion emulator which is very fast and lightweight
Genymotion
It might still work if you launch the emulator from the command line with the -no-accel switch:
Go to your SDK install directory
Go to the tools folder
Open a command/terminal window
Type emulator -avd Nexus_5X_API_23 -no-accel (replace Nexus_5X_API_23 with the name of the AVD you've set up in Android Studio / Android Developer Tools)

Categories

Resources