Android Device Vanishing - android

I have a really serious problem which is preventing me from doing Android development at work, which I have a strong imperative to get fixed as quickly as possible.
So, I plug in my phone to my OS X machine. I go to the terminal and I do this:
rutski#imac:~$ adb devices
List of devices attached
3331833A243A00EC device
Now, that looks good so far. But if I do some work for a few minutes I'll eventually get an error somewhere during "adb install", and when I run "adb devices" again I see that now the device is NO LONGER THERE!
So I unplug the phone, and plug it back in. I run "adb devices" and see the device back again, expect the cycle will repeat, and it will reliably disappear after a few minutes.
But it gets better. DDMS for me is completely unusable. I open up an OS X terminal and run "ddms" from the command line. A window pops open with a device list, and my device is there. However, if I so much as click on my device, it will vanish from the list, and I'll get this in the terminal window:
08:26:05 E/EventLog: device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.AdbHelper.runLogService(AdbHelper.java:469)
at com.android.ddmlib.AdbHelper.runEventLogService(AdbHelper.java:445)
at com.android.ddmlib.Device.runEventLogService(Device.java:290)
at com.android.ddmuilib.log.event.EventLogPanel$8.run(EventLogPanel.java:454)
Yes, I've made sure that USB debugging is enabled. I've done a start-server kill-server with adb. I've rebooted both the phone and my machine several times. Nothing fixes the problem.
What the heck am I doing wrong here?
EDIT:
I just noticed that after rebooting my machine things are stable until I run an app that crashes via something like calling a method on a null object; that's when the device first vanishes from DDMS, and it is flakey forever after. Still, I'm confused about what to do here. I need to be able to debug crashes, and they will happen.

Related

Cause of android adb "usb device not found" problems?

I've found a variety of questions here talking about solutions to the "usb device not found" problem when using adb, but I haven't found any explanations about what's going on or if there's a long term fix.
When I'm developing I'll write some code then hit run or debug, watch the results on my device then repeat the process.
Every now and then, perhaps once every few days, I'll get the "usb device not found" error.
The first thing I try is to open up the task list and kill adb.exe. That sometimes works.
If that doesn't work the next thing I try is to kill adb.exe then disconnect the android device, reboot it, then reconnect it and then run "adb usb" from the command line. That almost always works.
If the above doesn't work then I'll reboot the android device and also reboot the computer. That seems to do it for all the remaining times that the problem occurs.
Does anyone know why this happens and if there's a way to prevent it from happening? My only theory (based on not much) is that perhaps the device gets hot (due to heavy cpu usage during development and debugging) and does something wrong which messes with the way adb does things.
I had the same problem. I ended up having to go to my computer/properties/advanced system settings/environment variables/ , click "PATH" , then paste ";c:\Android\tools;c:\Android\platform-tools" as the "variable value"
then i went into device manager - my computer/properties/device manager and seeing that the droid had an "!" by it. I then downloaded and unzipped android ADB into a file on the desktop. and then back in device manager installed the driver by right clicking droid/then clicking update driver software , and selecting the file on the desktop and it, voila.
it took 20 seconds.

Adb stops detecting my phone after a while

I am developing for android on a linux machine and I have already created a udev rule for android and it works. After a while if I unplug the device and plug it back in again, adb doesn't recognize the device if I run lusb or dmesg to get information about the device. I tried reload the udev rules and it does not work, I even tried to kill the adb process but it still does not work.
Can someone help?
Anyway, thank you.
This appears to be a real problem on linux, at some point in time a device will no longer be seen by the ADB. What I should really say is almost never be seen by the ADB. In my case I have a Samsung Galaxy Tab 10.1 that was given to attendees of Google I/O 2011. My Ubuntu 10.10 development system was working just fine with this device. Sometime near September 19th the ADB stopped seeing the device! In fact there have been breif moments in time when the device was detected by the ADB. What needs to be made clear about the problem that I and I believe pharaoh are having is not the permissions issue where executing
$adb devices
returns ?????????? for a device. The device simply does not show up in the list. One more important fact is that at no point in time has this device not been detected on my Windows based development machines.
It appears to me that the mechanism that the ADB uses to determine if a device on the USB is in fact a adb_device is fragile and some change in either our devices or our development systems has broken this detection.
Due to some reason sometimes adb gets disconnected, so in that case you have to restart the adb.
Go to DDMS->Devices and you will see Reset adb option in View Menu besides Screen Capture option.
I usually have this problem due to I have installed the adb plugin on Chrome. If I close Chrome and re-connect the device, it appears listed with adb. Hope this helps.
I just had this problem as well with my OnePlus 2.
It was working the previous day. I had then set up port-forwarding using the 'device inspector' dialog in Chrome DevTools. It's supposed to be kept open for it to work, so I kept it open in a tab permanently.
The next day when I connected my device via USB, adb devices didn't list anything. I closed the device inspector dialog in my devtools and suddenly adb recognized my device again. I re-enabled port forwarding after this, but my device is stll being detected.
tl;dr: Close your port-forwarding dialog in Chrome DevTools if it had been kept open even after you removed your device.
I've had this happen before. I disable, and then re-enable debugging on the phone (Setting -> Applications -> Development -> USB debugging, uncheck, then re-check) to get it recognized by adb again.
Try adb kill-server to stop the adb and use another command 'adb devices' to restart it. It should work and it should detect your device again. ( For those who can edit my post: any other commands will start the server not just adb start-server, so don't edit without to leave a comment at least)
May be stupid, but I have been had similar problem right now and after an hour I noticed that the problem was that my USB hub, in which such devices are connected, were not actually connected to the PC.
In fact, the USB wire WAS connected, but they may not being doing good contact for some reason, so it failed randomly from time to time.
Same problem here, using mac os. However connected devices are recognized by Android File Transfer application. It all started with S3 phone (rooted), I thought something wrong with the phone, because Nexus 7 (stock) worked as intended. After 3 days of connecting/reconnecting it stopped being recognized by adb too. Tried to perform a hard reset - didn't help.
adb list - empty list
android file transfer - works perfectly
I'll run out of devices soon
Same problem observed on ubuntu, I tried the following and it worked:
Reference: link
Use the command udevadm from the above reference for ex:
"sudo udevadm test --action="SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="[vendor_id]", ENV{ID_MODEL_ID}=="[model_id]" MODE="0666", SYMLINK+="[Device_Name]"" $(udevadm info -q path -n /dev/bus/usb/001/[DevNum])"
This seems to fix some link files and that solved the problem of adb not detecting device after a while.

App won't launch on the device

No matter what app I try, it won't launch on the device. It works perfectly on emulator, but when I try to launch it on the device, it'll get uploaded & installed and then "Starting activity on device " appears and nothing happens - it just sits there and does nothing. When I repeat the process, eventually it will launch (but it has to be repeated like 5-10 times), but all those activity launching processes seem to remain active, which causes my phone to lag. I tried resetting adb, reinstalling Google USB drivers, nothing helps. I have a rooted phone, and custom ROM (it's called Darky's ROM 10.2) - could that be a problem maybe?
Sometimes it takes a long time to install and run, and ADB times out. Go to preferences in Eclipse, then to Android -> DDMS -> ADB connection time out (ms), and set it to something like 30000
You can try many things:
Compile and run a sample app on handset, does it run or not? If it doesnt then there may be a compilation environment (your PC) issue, signing or something else.
Download a free app from marketplace and see if you can run it.
Is this a standard Android phone or a rooted one? if its rooted then try on a standard handet.
Before installing do "adb kill-server" and then "adb start-server" to restart the adb. This may not be useful, but, just in case.
After installing the app, can you see it in Settings -> Applications -> Manage Applications menu?
Try a hard power cycle, by removing the data cable/charger and removing the battery for 10 seconds.
Also ensure that the emulator had the same screen dimensions as the handset you are testing on.
Attach Logcat and see what shows up there.
These tests will give you better idea of what is happening.

Android Debugger (on Netbeans7)

I just started using the ADB Log yesterday (Window -> Output -> ADB Log) and it showed me where my error was coming from as debuggers should. However, when I started it up today it won't show anything other than Error - No devices found then it tries to reconnect in 10 seconds. Eventually it just states that the device is offline.
I have the emulator up and running and replicated the error I had yesterday but still nothing useful from the debugger shows up. I haven't changed anything since yesterday and am not sure why I'm having the issue.
Does anyone know of any possible fixes?
Quick tip (this may or may not solve your problem): In your DDMS view, if the device isn't selected (in the left list of devices with their running processes), then nothing will display in logcat.
Also sometimes I have to run the following command when adb starts acting buggy:
adb kill-server
adb start-server (or adb devices)
EDIT: This is for Eclipse - not sure about Netbeans
Also: I have found that some cables do not work with debugging, only charging (these are cheaper cables). I had something like the same issue, once I used a better cable it started working.

Reconnecting Emulator to Eclipse

My main problem with developing in Android is that the emulator seems to continually get disconnected from eclipse. This always happens the 2-3 time I try to upload my .apk from eclipse without rebooting the emulator. Eclipse indicates this with an empty DDMS ->Device section and logcat stays blank - sometimes I'm not sure if the new code made it on the device.
The only fix I have for this is to shut down eclipse, and restart it. With the restarting of Eclipse, on top of the emulator boot time, I can't get any momentum going in my development.
Is there a way to reconnect the emulator to eclipse without having to restart Eclipse or even the Emulator?
Update: There were a couple of answers that helped, particularly "reset adb" or Kill-server -> connect adb. However, sometimes even that is troublesome.
I am going to try Pentium10's suggestion of hooking up my G1 and using it as an emulator, but for now, I have found that if I don't see my logcat going, and the emulator is working (This is my biggest problem, because I am outputting all my debugging messages to log) then I can open up CMD and type adb logcat. This streams the log into the command window. Not nicely color coded, but nice enough for me to find my problems...
In eclipse go to Window->Show View->Other->Android->Devices. When your application is run go to this tab and you will see the emulator. If your emulator becomes unresponsive, in the devices tab you will see a down arrow at the right. Click the arrow and a context menu shows up. Hit the option Reset adb.
Just had to do this and it worked beautifully, but it did require you to reset the emulator - though I didn't wait to see if it reconnected on its own.
Try to call 'Reset adb' menu item from DDMS > Devices tab. It helps me in this case.
At most of the time you don't need to restart the emulator.
AFAIK the only workaround for this is to restart Eclipse (I always use this), or use a real phone.
Try adb kill-server, followed by an adb connect
I've had luck reconnecting to the disconnected emulator by entering an adb-over-tcp command line which you can look up in the docs. I think the address and port to use are the ones in the title bar of the emulator window, if not try the next higher port. Once it's back in adb devices eclipse should use it.
in terminal:
$adb kill-server && adb start-server

Categories

Resources