Capturing network activity in android emulator - android-emulator

I know there are numerous threads on how to capture network traffic using tcpdump, wireshark etc. I tried enabling -tcpdump emulator1.cap in Eclipse > Run Configurations. But I don't know where
this data is captured. Can someone please let me know the step by step instructions on how to use tcpdump to capture traffic?

It is stored on the PWD of the emulator. If I start the emulator from the command line, like
$ emulator -tcpdump emulator1.cap -avd x86
then I get a nice emulator1.cap file.
Using Eclipse you'd probably like to do an absolute path.
Try writing -tcpdump /tmp/emulator1.cap or -tcpdump C:\emulator1.cap (on Windows)

In my case I tried doing that but I got some emulator warning like:
emulator: WARNING: The -tcpdump flag is not supported in QEMU2 yet and will be ignored.
By the way, the command I issued in the console is /path_to_sdk/sdk/tools/emulator -tcpdump /path_to_save/emulator1.cap -avd Nexus_7_API_22.
Does anyone have ideas about what image or engine does the emulator support tcpdump flag?

Related

Chrome remote connection connects but then drops out

I am really struggling to get Google Chrome Remote Debugging to work! I have the phone setup and confirmed:
Then below are what I see in chrome://inspect/#devices and also F12 (both open at the same time);
It flashes with the "Connected" for about 3 seconds, and then goes to:
Offline
ZX1G324RSV Pending authentication: please accept debugging session on the device.
It's driving me nuts, as it should be simple to do, but it just doesn't want to play ball :/ Do I need to do anything special? I've used it before on this PC and although I had some fun and games with it the first time around, it worked after that.
There seems to be a ton of posts/articles about how to fix it, but none of them are working for me. https://bugs.chromium.org/p/chromium/issues/detail?id=450492 for example.
Download Android SDK here ("SDK Tools Only" section) and unzip the content.
Run SDK Manager.exe and install Android SDK platform tools
Open up the Command prompt (simply by pressing the windows button and type in cmd.exe)
Enter the path with ex: cd c:/downloads/sdk/platform-tools
Open ADB by typing in adb.exe
Run the following command by typing it and pressing enter: adb devices
Check if you get the prompt on your device, if you still can't see your phone in Inspect Devices run the following commands one by one (excluding the ") "adb kill-server" "adb start-server" "adb devices"
Here are the things that you can try:
Try different USB cable(s)
Try different USB ports on your machine(for some people using 2.0 port worked out)
Try the same process, with unchecked 'Discover USB Devices' in chrome://inspect (then Chrome will connect through the ADB server, not directly) ==> This solution worked in my scenario.

Can't get Android Emulator to work in Linux

I have Fedora 10, it's an old machine.
When I launch the Emulator, it comes up, but I don't
get any initial "Android" display text on the screen, and I've tried
waiting ages.
I installed the Java JDK 7 first then 'android-sdk-r22.2.1-linux.tgz'
and I even set the "alternates" for Java.
I've tried several Emulators, like the 4.3 with the armeabi
and an earlier 3.2. I also tried launching them from the command line with:
emulator -no-audio -gpu off -avd [AVDName] and I even tried '-force-32bit'
but nothing is working.
I've used the Emulator on Windows for a long time, so I'm
very familiar with how to use them, but I just can't get them working on Linux,
what can I try?
Thanks!
This will work:
1) Create a Phone in Eclipse using the Android Virtual Device Manager
(Navigation Bar | Window | Android Virtual Device Manager)
2) Open a terminal in: yourInstallationFolder/sdk/tools
3) Type: ./emulator #theNameofYourPhone -force-32bit
I had exactly the same issue, with the latest build tools - emulator would not launch, adding -debug-init showed that it couldn't get past this line:
ping command: /path/to/android-sdk-linux_86/tools/ddms ping
emulator 22.3.0 "NVIDIA Corporation" "GeForce 8600 GTS/PCIe/SSE2"
"3.3.0 NVIDIA 331.20
But sometimes it worked, it got past this and printed some debug info about display surface, pixel format etc - then emulator was working.
I tried soooo many things, none worked, but it seems I found the solution!
It looks like emulator always starts OK if I launch it from the first virtual desktop! And not working, 'hanging' - when launched from others.
Took some time to figure out, because my main 'development' virtual desktop is a second one :)
Dunno whos bug this is, NVIDIA's, xorg's or emulator's, but I hope this workaround will keep working :)
I have been pulling my hair out on this issue all week... I finally just tried a different DE. I launched an icewm session and the emulator is not running just fine. It seems to be an issue either with GTK or KDE's WM.
Any ways, I hope this helps solve the issues you might be having.

Frozen Android emulator due to audio problems?

Today I installed the latest version of Eclipse, Android SDK and AVD plugin. But I have a tedious problem. When I want to quit the emulator (with the X button), the emulator freezes and I can't click anything there anymore. Obviously it has something to do with the sound, because when I execute "pulseaudio -k" in console, the emulator quits.
Due to this fact, I tried the following to let the emulator at least run properly:
In Preferences->Android->Launch -> Default Emulator option -> -noaudio
and
Run Configuration -> Android Application -> [Application] -> Target -> Addidtional Emulator Command Line Options -> -noaudio
But nothing helps. Emulator stays frozen. Actually I want audio to run, but switching it off doesn't work either. So what can I do?
I replied on the issue, but just if interested:
you may need to disable audio output instead, this is not desirable for me, so just select alsa (or esd/oss) by setting environment variable
QEMU_AUDIO_DRV=alsa
Looks like there is no way to specify audio drivers in hardware.ini so the best solution is going to sdk tools directory, rename emulator in emulator.real and make a shell script named emulator containing:
#!/bin/sh
export QEMU_AUDIO_DRV=alsa
exec $(dirname $0)/emulator.real $*
then chmod 755 emulator
It's this problem described here:
http://code.google.com/p/android/issues/detail?id=17294
There is a workaround so that you can quit the emulator:
Set in your virtual devices "Audio Playback Support" and "Audio recording support" to "no".

Android emulator reports unknown virtual device

i am having the same problem described in the following post "Android emulator reports unknown virtual device" Why does the Android emulator report "unknown virtual device", when the device is in my user directory? and have followed all of the instructions in an attempt to resolve but still i cannot run my AVD.
I only have one drive on my Windows 7 machine (C:) and the AVD is being created in the correct location -> C:\Users\MyUser\.android
Ive also tried to setup an environment variable "ANDROID_SDK_HOME"
The actual error is:
emulator: ERROR: unknown virtual device name: 'my_AVD'
emulator: could not find virtual device named 'my_AVD'
Can someone please help me?
For another reason i had to re-format my pc. After a quick rebuild its working fine now. I think the problem happened because in the previous installation of windows, i was playing around with HDD's. Somehow this had caused problems..
Solution: you should have a copy od .android in C:\<your user name>\.
Please try the below steps to solve the above issue -
in task manager kill adb in process
in android sdk folder .. /tools/ run adb kill-server in command line
Check the avd folder name in " ../.adroid/avd/" - say it is "avd1"
run command "emulator -avd avd1 " under android folder "../tool/" in command line
it will start the avd1 device
Now start the eclipse and run your project with setting the "manula" option in configuration.
It will ask for choosing the avd between "avd1" and the existing list of avd's in eclipse if any. You choose "avd1" as it is already running.

Android Emulator sdcard push error: Read-only file system

I am developing under Android 1.6 (Android SDK 2.1).
I create a avd by using avd manager in Eclipse.
When I launch this avd, I found that the /sdcard directory's permisson is "d---------".
So I can't push file to the sdcard.
Does anyone know how to solve this problem?
I found this works
$./adb shell
$su
mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard
exit
Source: http://www.coderanch.com/t/611842/Android/Mobile/Android-emulator-sdcard-writable
Once you started the Emulator from one shell, login to another shell & type
adb shell
You should see # prompt displayed, this is your device(emulator) shell. Now , type following command at adb shell.
mount -o remount rw /sdcard
This will now remount /sdcard with rw(read-write) permission & now you can push your files into /sdcard by using following command from your host shell.
`adb push filename.mp3 /sdcard,`
where filename.mp3 could be any file that you want to push into Android Emulator.
Hope this helps :)
Ensure two things in the AVD manager utility for the emulator:
SD Card size is mentioned e.g. 512.
From the Hardware tag, press New and select "SD Card Support" from the drop down menu.
Now, start the emulator. SD Card shall now support writing as well.
Android studio version 0.8.9 and above has a bug creating AVDs.
See Issue 78434.
Workaround
go to your ADV folder in .android folder and find your AVD config.ini
open it with a text editor that can handle unix newlines. (Notepad will run the lines together since they don't have CR-LFs.)
change hw.sdCard=no to hw.sdCard=yes
this should work for everyone in new builds
Maybe it sounds stupid but it worked for me when I had the same problem: delete the created avd and create one again through AVD Manager with a sd card of, for example, 512MB.
Check that both have the correct permissions and if not, try to change them with chmod.
And if everything still fails, repeat the process but creating both avd and sd card manually via terminal:
android create avd -n my_avd -t 7
mksdcard -l e 512M mysdcard.img
emulator -avd my_avd -sdcard mysdcard.img
Hope that helps!
I think the problem here is that you forgot to set SD card size
Follow these steps to make it work:
step1: close running emulator
step2: open Android Virtual Device Manager(eclipse menu bar)
step3: choose your emulator -> Edit -> then set SD card size
This works well in my emulator!
Make sure that you had given a value which is greater than zero for SD Card size in the Create AVD Window for that particular emulator.
mount -o remount, rw /sdcard
this is the correct way to remount your sdcard using your emulator.
I tried #user2002993 great help but it one place it need to be a little edit so I edited and here what worked for me on Android Studio, emulator android 5.
Go to your adb folder right click on blank area and select "open command window here" or if you installed adb by adb-installer open cmd and type these commands:
adb devices
It should show your emulator number and detail. Then followed command here:
adb shell
Now it should show you prompt #
su
mount -o rw,remount rootfs
chmod 777 /mnt/sdcard
exit
exit
Yeah double exit needed, now your prompt of adb shell is gone. Put a file in to your adb folder and give this command and see if it got fixed.
adb push "your file name like : 1.jpg" /sdcard/
or
adb push "your file name like : 1.jpg" /storage/sdcard/
Now in cmd it shoudl show you transfer time instead of creepy read-only thing 😊
I increased the virtual memory of sdcard up to 512 MB for the emulator and that was enough
I guess, you didn't insert memory size at the time of creating avd. you can do that by editing the avd.
make sure that you have the correct permissions.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Windows uses backward slashes, linux uses forward slashes.
sometimes this can cause of a very simple reason,
go to your list in eclipse and check whether you have set SDCard size
I had this problem on Android L developer preview, and, at least for this version, I solved it by creating an sdcard with a size that had square 2 size (e.g 128M, 256M etc)
In adb version 1.0.32 and Eclipse Luna (v 4.4.1).
I found a directory in the avd /mnt/media_rw/sdcard that you can write to using the adb command.
adb push {source} /mnt/media_rw/sdcard
There appears to be rw access to this directory.
Hope this helps :-)
Alternate way:
Dismount the drive (from settings/storage) and re-mount the sdcard
also fixes the problem. (verify by moving a file from internal storage to sdcard)
In any case, this simple method saved my butt this time :)
Give any size to Sdcard in Emulator
unchecked the read only option from c:\user...android\avd -> properties
push a file through file explorer
restart the Emulator
It will definitely works
With me in the end helped
In the emulator to run applications manager
and setting permissions for storage.
Try this in a Terminal Emulator as root:
restorecon -v -R /data/media