I am trying to perform adb interactions through python code.
I have an endless executable on the android device which i would like to start and after 10 seconds kill it.
right now, i can get the program to start but cannot kill it other the manually pressing ctrl+c.
procID = subprocess.Popen(["adb", "shell"], stdin=subprocess.PIPE,)
procID.communicate('su\n endless_program data/test 5\n')
time.sleep(5)
os.kill(procID, signal.SIGINT)
procID.kill()
i tried killing it with os.kill or procID.kill but both don't seem to work.
I have also trying using pexpect, but for some reason i cant get it to run adb.
You are just killing the adb shell session, which won't kill the running application. If you would like to kill the running Android application, you have to stop the app over the adb shell. For details have a look at this stackoverflow answer.
I need to forward a port on an android emulator, right now I had to type the command every time:
adb forward tcp:23946 tcp:23946
Is there any way to make this automatic? I tried to replace adb with a script but that command won't work until the device is up and running.
Any ideas?
Based on this answer (which I've tested and works, though it wasn't for a scenario like this one), you could simply write a script that waits until the emulator is booted.
Something like (pseudocode, don't know which platform you're on) :)
emulator #emulator-name
while ('adb shell getprop init.svc.bootanim' == "running") sleep(10s)
adb forward tcp:23946 tcp:23946
I can see there are 4877 messages in total in my logcat but when I select the "All messages" filter, nothing is there.
I have tried the following:
adb kill-server
adb start-server
Of course, I went to DDMS and select my 1 and only device (a real handset, not an emulator) but it didn't solve the problem.
I can certainly view logcat messages using adb logcat command but it's very difficult to see compared to logcat in ADT.
Restarting ADT does solve this problem but it's happening way too often and you all know restarting ADT takes time.
Note that the "All messages (no filters)" filter is only an example here. The same issue happens to the custom filters I've created as well.
It doesn't always update that value when you clear it or if they get pushed out of the buffer. As long as you don't tamper with ADB or manually clear it it the 'No Filter' option should stay full though.
I am interested in running
adb shell setprop log.tag.Volley VERBOSE
at all times so i can see always see these debug messages inside logcat. Is there somewhere I can perm specify this? I don't want to open a command prompt every time to set this.
to make my comment clear and visible as answer:
using leading word persist. prior to your package should lead to a persistent property.
adb shell setprop persist.your.package.name VERBOSE
sources: question in this post and Mike Lockwoods first answer in this thread
i don't know, if this works with AVDs that are restarted and if it's wiped together with the wipe user data of the avd.
Sometime just after I launched a new emulator, for very first time I was trying to upload my apk, however I got "emulator: ERROR: the user data image is used by another emulator. aborting".
I launched a new emulator, and left it alone, several minutes later, DDMS showed "device offline".
I had to restart a new one, you know, minutes wasted.
It's really bothering that I keep getting this error and slowed down debugging.
How do I fix it?
If the emulator is still alive, you can tell adb to connect to it via tcp (which is I believe what it does anyway, only it normally uses an 'emulator' class of name and would now get a ip:port one)
It's been a while since I've had to do that, but I think that if you were using emulator-5554 you would connect to your development machine's loopback one port higher, ie:
adb connect localhost:5555
If it works adb devices will show it an eclipse should see it as a deployment option
The 'in use' problem sounds like a stale lockfile perhaps left behind in a crash
I have another solution. try this
Run configurations > Target > Wipe user data > Run
In my case it happens when I have another process listening on emulator port.
e.g. if I see:
emulator-5554 offline
it means that something is using port 5554
Manually delete these following folders:
C:\Users\%UserName%.android\avd\AVD2.1.avd\cache.img.lock
C:\Users\%UserName%.android\avd\AVD2.1.avd\userdata-qemu.img.lock
this always works for me. :3
On Arch Linux x64, I had this similar problem which led me to this question. Using Eclipse, the emulator-5554 window would freeze, and Eclipse prompted me to start a new one. In the following dialog, emulator-5554 was reported to be offline, with an unknown target. If I started a new instance, it would be emulator-5556. This problem persisted through Eclipse restarts and log-off-on cycles too! Further, killx would close the window, but the process was still running.
So, find the emulator64-arm process id (not emulator-arm!):
ps ax | grep "emulator64-arm"
...and then just kill -9 it:
sudo kill -9 6728
...where 6728 was its PID. This completely disconnects the emulator so Eclipse can try to run it again.
Open android debug monitor window by
typing "monitor" command in cmd,
then select device in the monitor window,
click on down arrow as shown in the figure then just click on reset tab thats all you will get internet connection.
It was some strange
I had that problem, automatically stopped the emulator localhost:5554 after to launch the application.
I didn't know why it happens but intil today I did something different at I could launch as normality.
What I did as different was to change the prespective of Eclipse ADT. I was executing the application from Debug and now I executed from Java Prespective, it worked, I don't know the reason, I had to share it, sound some .. this answer but I resolved doing that without deleting and creating again my android virtual device.