I have an Android device (with Lollipop image, if important) running in Genymotion 2.4 and connect to it via ADB (version 1.0.32) from another developer PC with Eclipse in local network without connectivity problems. All is fine except for periodical drops of ADB connection (other protocols keep working fine), that is ADB loses the device, and when I try to reconnect it says that device is offline. From my experience, this offline status does basically mean that the receiving end (the device) still thinks it's connected and declines new connection. The only method I know to remedy this problem is to restart the device and then ADB connects to it as expected.
If someone is interested, ADB is not running on the remote host machine with Genymotion - otherwise the remove connections from other PCs would be impossible.
The question: how can I refresh "softly" the virtual device to accept new ADB connection without restarting entire device?
P.S. If I leave the "offline" device for its own for some time (quite a long time, for example, for an hour) it seems refreshes its state without external interaction, so ADB is again able to properly connect to and device is reported as "online". But, it makes no sense to wait so long for this to happen. This is just a new piece of information for consideration.
This may not work for you, but has worked for me in the situation where my device simply goes ADB offline. One of the comments on your question mentions that their emulator typically goes offline when their device sleeps. Mine does the same and also goes offline after long periods of inactivity, despite not actually sleeping. Anyway, my fix is plain and simple:
In terminal, navigate to where you have the SDK installed. Then, navigate to the directory platform-tools within your SDK, and issue the following command:
adb kill-server
After that finishes, type this one:
adb devices
That almost always fixes my problem, and I hope it fixes yours as well. Let me know how that works for you.
If you use MacOS Sierra - there is a known bug in it.
28.11.2016 There is no workaround yet except restarting adb which is suggested in #lustig answer.
Google gonna fix it in Android Studio 2.3. Issues to track 82425, 216214
There is no info about will Apple fix it on their side or not.
Related
I am using chrome://inspect/?#devices to connect with my android device.
After ~20 minutes my device gets disconnected automatically every single time.
After it gets discontinued my device asks for allowing usb device again. And if I run adb devices on my Mac, I am unable to see my device since it got disconnected.
I wanted to know the why this is happening and is there a fix available for this or not.
Aim: I want to connect my android device at least for 3 hours without interruption.
I have tried this with multiple devices, multiple data cable and multiple physical conditions but I don't think the issue is from hardware side. USB Debugging is on and the connection stays for a few minutes without any issue, everything works fine for some minutes(not fixed but it is around 20 minutes).
Adding images of my android device and macbook after the connection gets disconnected:
If you are facing similar issues then 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.
I created an AWS EC2 instance, installed ADB on it. I then created an image of that AMI and launched 10 more AWS EC2s with it. The AMI made sure that the adbkey present in ~/.android/ location remains the same across all 10 instances. Now I assumed that if I trust one instance with a device all instances should automatically get trusted as all of them are using the same key. The theory works well, and all instances can connect to it. I have been though facing multiple flakiness in this approach
Often times, I see that when I execute adb connect deviceIp It says that connected but when I go to devices It shows device offline. I tried adb kill-server && adb start-server but no help. I tried restarting the device, no help. Furthermore, I used another instance and sometimes that connects and sometimes not. This led to me thinking that I should disconnect an instance after using it because maybe multiple instances cannot be connected to a device at the same time. But that does not work either.
Another unique scenario, where after adb connect deviceIp when I execute adb devices it does not show, however it gave a confirmation about connected. For this, I tried toggling ADB debugging off and on, which sometimes work and sometimes not.
This is ok for ad hoc purposes, but I am trying to create a stable system to execute automation on multiple devices and hunting for something reliable. Am I missing something, otherwise ADB is turning out to be highly unreliable?
I made a program to backup files in android devices. To put it simply, it works in background of Windows like a server and when a defined android device (with its LAN IP) connects to home's WiFi network it looks for specific files in specific folders in device and backups them.
My problem is, for some devices (e.g Samsung Note 4), after a few successful WiFi connections (or a few days later) the device starts to appear offline. To fix this, I need to reset the authorities in device or do the reconnection procedure of my program with USB cable again. I researched the web in-depth but couldn't find a way to make offline devices online automatically.
Most of 'ADB offline' solutions on the web works well, but i need to do this automatically over WiFi within my program.
-ADB kill-server & start-server, not working,
-ADB disconnect & connect, not working too.
Disable your antivirus and then try again or add adb.exe as exception in your antivirus.
So, let me start off by saying that I am 'relatively' familiar and comfortable with making Android apps and using both LogCat and DDMS to debug.
That being said, I'm encountering more of a logistical issue than anything else right now - I am making a locative app, where the GPS is fuelling and controlling other methods in my Activity, and after a while, it is crashing.
Now, because it is locative, I am walking around to test it, in order to receive different GPS locations. Because of this, I am not connected to my computer at the time that it crashes, so have no way (that I know of) to read the stack trace, etc.
In my particular instance, I am navigating through a series of activities, and finally reach the penultimate screen in my app, and while I am running the application in my studio, it runs indefinitely without issue. It is only when I take the device outside that it crashes...
I am wondering if anyone has any tips or tricks with this issue - I'm sure give the prevalence of locative apps, it must have come up, but I cant seem to find the right search terms. It could be as simple as saving the LogCat to file, and/or the stackTrace, but I'm not sure that's the answer...
Thanks in advance.
If I got you right, this is what you are looking for:
https://play.google.com/store/apps/details?id=org.jtb.alogcat&hl=de
Edit: Also there are many more apps like this. You can just browse around in Google Play Store
You can debug the app without rooting your android, unlike the other responses. start off by plugging the android into your computer, then run adb devices to make sure the device is there. Then, run tcpip 5555 to change the android to tcp mode, which will allow debugging over wifi. Disconnect the android from the computer, and connect to it by typing adb 192.168.x.xxx, replacing the x's with your android's IP address. It should connect with no issues, as long as port 5555 is open, and both the android and your computer is on the same wifi.
Simple: Wireless ADB
One of the reason that I choose to run CyanogenMod on my testing devices is that it is a stripped down version of Android that has some additional developer tools, one of those being the ability to access the wireless portion of the ADB system.
As you are probably unaware, you are able to establish an ADB connection to your device over WiFi, however, if running a stock ROM, this requires root access, as it can be potentially harmful to your device, as Wireless ADB will work even over your cellular network, meaning that you could potentially receive apps from other insert carrier here's devices.
If you wish to run WirelessADB, here is a Play Store app that will help you to enable the feature on your device. Requires ROOT
It is as simple as connecting your device to your local WiFi network, (same one the development computer is connected to), enable Wireless ADB, and then running the following command on your computer:
adb connect 192.168.1.101
Replacing 192.168.1.101 with the IP address of your android device.
By establishing this connection, you can run everything just as you would if the device was plugged in via USB Cable.
I recommend ACRA (Application Crash Reports for Android ). It allows you to send crash reports to a number of different destinations. See https://github.com/ACRA/acra/wiki/BasicSetup
I have made a mistake somewhere in my code that my Android app crashes when I switch off the network in the emulator while the app's HTTPClient is making some request.
But I cannot debug it, because when I switched off the network, I also lost the ADB connection. Thus I cannot see what exception is causing the crash.
I have tried switching off the network by:
F8
Set 'Data' to 'Unregistered' or 'Denied' in DDMS Emulator Control
I can put my Mac offline and ADB will stay up, but unfortunately I cannot reproduce the crash that way.
Is there a way to turn off network in the emulator, while keeping ADB alive? I basically need access to the LogCat entries.
Thanks!
You can run logcat from the device instead of from ADB and redirect it to a file for offline reading.
adb shell logcat [-v threadtime] > /sdcard/mylogs/logcat.log
Instead of
adb logcat [-v threadtime]
Then you can get the file when you reconnect to the device.
On linux this is pretty simple with iptables firewall. I suppose you trying to debug api calls so just block api host:
iptables -I OUTPUT -d api.example.com -j DROP
Sure you can do the same thing with Mac or Windows firewall.
You could always put the device into airplane mode, that will still allow you to connect over adb but not give the emulator a connection to the internet. You can also turn off data through eclipse via the emulator control section in ddms by putting in unregistered/denied to the data drop down.
I know this is old question but someone might use find for this.
My setup
Eclipse Kepler with emulated android 4.4
If you want to keep your adb alive and network turned off, you can try this.
Start emulated device
Activate flight/airplane mode
Restart Eclipse
It should work! Check DDMS perspective for attached devices or use adb devices command