Android Debugger (on Netbeans7) - android

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.

Related

Android debugger continually disconnects

I have never had an issue debugging in Android until I switched to my current workspace. It happens in both Eclipse and IntelliJ. Previously I had an issue where the phone would hang at the "Waiting to attach debugger" dialog. Somehow I fixed that so the debugger at least attaches to my app.
Now I can set a breakpoint and have the debugger stop at that point. After about 5-10 seconds it disconnects no matter what I do. I'm able to read a few values of variables in memory before everything disappears. My co-worker is able to debug the same app just fine using Eclipse and we haven't been able to figure out what is wrong or different between our workstations (besides me using IntelliJ). We might have different images for our laptops though.
Any ideas? I've had to use Log statements for now but they are just too slow compared to using an actual debugger. I've tried using different USB cables and that didn't make much of a difference. I've gone through the debugger settings and nothing seemed out of the ordinary. Other Q/A's on SO have mentioned the app silently crashing, but I'm ruling that out due to it debugging fine for my co-worker.
I've been having the same problem running IntelliJ IDEA build IC-133.193. I solved the problem with the following actions:
Quit IntelliJ
From a command line kill the adb server with adb kill-server
From a command start the adb server as superuser with sudo adb start-server
Restart IntelliJ
IntelliJ will start the adb server if it detects that it is not running. The key appears to be starting adb as superuser before starting IntelliJ.
[Update] This doesn't always work. The best solution I've found is to start the app on the device and then attach the debugger to the Android process through the Run menu. I haven't had any disconnections using this method.
I have been fighting for a few days with adb not seeing my device. After trying many other posted solutions, I discovered that the issue was with Chrome also trying to connect its debugger to a web view. If Chrome is connected using chrome://inspect, then adb seems to disconnect. Quitting Chrome resolves the issue. Then I can connect with Android Studio and then restart Chrome and reconnect. Hope this helps someone else.
This fixed it for me
Go to Power Options on your computer
Click 'Change plan setting' on your chosen plan.
Click 'Change advanced power setting' on your chosen plan.
Expand 'USB Settings' .
Expand 'USB selective suspend setting' and change it to disabled.
This issue occurs to me when I try to use a USB 3.0 port. Using a USB 2.0 it does not happen.
This happens to me when the cable connection is sensitive.

Why won't my logs be displayed in the logcat?

I'm using Eclipse Indigo and up until just a couple hours ago or so everything was working fine. When I just relaunched it and made a couple changes, I ran the program on my phone but my logs were not being displayed. The phone's logs are displayed in the logcat, but nothing from the project is. I have the device selected, I've tried restarting eclipse multiple times, I've reset the ADB, and I've run the commands adb usb and adb logcat (which still doesn't display my logs). I know my logs are correct: Log.e("Tag","Message"); Anyone have any other ideas?
As it turns out, it was a stupid error on my part. I had my logs set up as: Log.e("Tag","") instead of: Log.e("","Message"). Apparently, if you have the former, it won't display to the LogCat, go figure?
I think, you haven't selected device or emulator , on which running your application,
In eclipse go to DDMS Perspective and select device or emulator on which you are running your application.
(Note: No need to restart the Eclipse)

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.

Android Device Vanishing

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.

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