I am trying to debug some USB attach/detach Intents while using USB Accessory mode to some custom Host hardware. I am able to connect ADB via WiFi TCP/IP and it works great. However, when a USB attach/detach Intent comes along, the ADB connection is broken - even though ADB is not running over USB at all.
After reading countless threads here that dance around that topic, a common suggestion seems to be that having "USB Debugging" checked in Settings will make the ADB connection sensitive to USB. Several posts suggest unchecking that box when running over WiFi/TCP. But I've tried that, and cannot associate ("adb connect 192.168.x.y") if that box is unchecked even when running over WiFi.
I have confirmed that when the box is unchecked, getprops still shows "service.adb.tcp.port 5555" like it always does. I've also tried explicitly killing and restarting the adbd daemon. Nothing works... except checking that box, at which point I can immediately connect via TCP.
So... what's the real story? I must say it FEELS likely that having that box checked would make ADB sensitive to USB even if it's not running on it. But is that box mislabeled, and instead of meaning "USB Debugging" it really means "Debugging regardless of connection type"? I really need to make ADB ignore the USB connection so I can debug attach/detach events. Any help appreciated. Thanks!
Related
I'm using scrcpy to mirror the phone screen to computer, which uses adb.
I've followed the steps and it works:
# connect via USB
adb devices
adb tcpip 5555
# now unplug USB, and the following will work over WiFi
adb connect 192.168.1.14:5555
scrcpy
But when you reboot the phone or computer, doing adb connect 192.168.1.14:5555 and scrcpy doesn't work anymore (NB: the phone IP hasn't changed, it's fixed).
Reading the answers from Run/install/debug Android applications over Wi-Fi?, I see 3 options:
plug the USB cable each time before doing a wireless connection, but this is annoying, and somehow reduces the interest of wireless...
Use "ADB over network" (main answer's screenshot), but as noted by many people in comments: "i do not have the "ADB over network" option in debugging option"; so this option doesn't work for me
other techniques that need root (not possible for me)
Question: how to pair the phone and computer with a USB cable only once, and then be able to use adb between them without having to use a USB connection first, after each reboot?
Note: I don't use Android Studio, but only scrcpy.
It's not possible without root the phone. If your phone has rooted. You can use this app. https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb&hl=en. With this app you can easily debugs android apps with only wifi. Don't want USB cable even only first time.
Based on all the information I have the next conclusion. Just for reference, how a low-level setup with changing add routes works inside, described here. It comes up, there is a pretty straight thing inside changing navigation with adb tcpip <port>.
The first thing we need to do, it's setup system property with tcp port with name setprop service.adb.tcp.port (and values with a port number) By default, there is not such property.
And then just restart adb with few commands. stop adbd and start adbd on a device in order to debug bridge listen new port. What is the trick here, that you don't have access to this service and stop/start it without root. But it could be easily done, via Developer setting with stop/start debugging.
This few simple action hidden inside adb tcpip <port>. And the problem, that you cannot change system properties (point 1). That is why all application requires root access, it's just to change the single option. That is why, we need to connect with USB to debug bridge, which can change properties with his sepolicy.
So answering your question. I don't understand either, what is the problem or enabling this small setup in Developer options. But right now, it's possible to do so on some Roms, or devices with root access.
I have read all the relative threads about ADB not recognizing devices. My case though is different: ADB sometimes "sees" my phone (Samsung Galaxy) and other times NOT. No matter how many times I kill and restart the ADB service or I disconnect and reconnect the device from/to the PC. Quite an unstable situation here. You know, it's one of these things that drives you crazy. That's why I resorted to your help.
Has anyone had this exact problem and resolved it once for all?
More info:
The PC has never a problem recognizing the device.
I try with both the standard SDK adb.exe and the Universal ADB driver adb.exe.
Either of the above have no problem recognizing the emulator.
Couple things.
1) it's a dumb suggestion but sometimes its as simple as this. Did you try more than one cable?
2) If yes, then try this. try as many times as you have to get it connected since u said "ALWAYS" so it does work sometimes. When it does work, open terminal or command line and run the following commands.
(make sure device is connected when you do this AND you are on the same wifi network)
adb tcpip 5555
then disconnect your phone and run the following command:
adb connect YOUR_LOCAL_IP
do this many times, this is wireless adb connection and if this works, its something with ADB or your computer and not the phone.
Let me know if it works. I might have more ideas depending on what result you get
============ EDIT ============
I believe it's offline because it says 8080. I just did the same with my phone and I get the following:
Try this: disconnect phone physically (if connected) and all other devices and make sure by doing: adb disconnect.
then, do adb kill-server
then, on your phone, go to Developer Options and uncheck USB debugging.
then, right underneath that options, there is Revoke USB debugging authorizations options. select and revoke all devices
then, check USB debugging
then, back on your computer, run adb start-server
then, try reconnecting with the steps I said before. make sure port is 5555
when you run the adb connect command, make sure to add the port at the end.
example: adb connect 10.0.0.15:5555
Hope this works.
Essentially, my problem is that I tried connecting my device to adb over Wifi, got to adb connect xxx.xx.xx.xxx but then adb claims that it was unable to connect to xxx.xx.xx.xxx:5555.
Ok, but now I'm having trouble getting it back to listening over USB. adb usb tells me that there isn't a device attached and adb devices gives me an empty list.
I've tried killing the adb server and then restarting it, toggling the device's debugging mode and toggling the device's USB storage transfer but nothing seems to be working. This question seems very similar to my problem but I have no idea what the guy is doing in the solution.
I'm guessing the problem is that adb is still trying to listen through Wifi but since I can't connect to it over Wifi it can never go back to listening to it over USB. Idk...
For wifi, you may be able to get it to work if you first use the browser on the device to visit a webpage or something and so effectively wake up the wifi radio and its connection to the access point. You may need to keep doing this every once in a while.
(Maybe you should listen to internet radio while you work?)
Of course your access point will have to permit peer-to-peer traffic on the local subnet. In many cases that may be the norm, but I believe an access point can be configured not to support that, and some may default to such settings. There can also be issues between wired and wireless subnets sourced from the same box.
Finally, restarting the device might get it back into USB mode.
I am working on a USB-based project so I'm using ADB over WiFi TCP/IP. Works perfectly, and frankly this ability to debug over a wireless connection is one of the coolest development tricks I've used in years. Really, really cool.
I'm working on the various Intents associated with USB connects and disconnects. I've found that anytime the USB cable's physical status changes - whether it's plugged in or unplugged - the ADB wireless connection is lost. I can reestablish it and resume debugging via DDMS, but by then a whole lot of CPU time has gone by. This makes debugging USB connection events basically impossible.
I cannot understand why ADB would still take action on USB events when it is connected via TCP/IP (over WiFi, no less). Is there an ADB configuration detail I'm missing? How do you tell ADB to ignore USB since it's not running over USB anyway?
Thanks!
I had the same issue and i think managed to solve it by "Revoke USB debugging authorizations"
I then connected over usb and allowed my PC
Then restarted adb in tcpip mode and connected to my device.
It stayed connected when I disconnected the USB cable.
Hope this helps.
I need network connection on my Android device to test apps. My notebook WiFi adapter is broken, so after 2 hours I've set connection via USB. But! Eclipse doesn't see the device when I start "Wired Tether" on it to get connection and I can't debug my apps.
Does anybody know how to solve this issue? Use USB tethering to get internet connection on phone and debug apps at the same time?
I don't know of a way to simultaneously use USB debugging and tethering. Here are some workarounds, though:
Get a USB wireless adapter for your computer (see http://www.amazon.com/gp/bestsellers/electronics/13983791/ref=pd_zg_hrsr_e_2_4_last). I don't know if buying one of these is an option for you in India.
Send your apk to your phone wirelessly for app installation (see Developing on android-based device via wireless) and then view the logcat directly on the phone for debugging (aLogcat seems to be popular, and allows you to send log files via, for example, email, so that you can open them on your computer to view them on a bigger screen)
I know these solutions involve some cost, effort, or inconvenience, but hopefully one will work for you.
EDIT:
As noted in answers from #shkschneider and #CodeShane, Internet sharing via Bluetooth is possible. CodeShane's answer mentions PdaNet (which apparently also allows for simultaneous USB tethering and debugging), and includes a link. Another solution is OpenGarden. These solutions provide access to the Internet for the computer via the phone. If the reverse is desired (and this is not entirely clear from the question), reverse tethering seems to be the answer (see the answer from #NickL).
Long story short: you can't. Android simply does not supports it (that is more because of the USB standard and tethering action than AOSP's fault).
So to go around the problem, you should either:
Get internet form another source
Maybe you could have ethernet connection?
Tether internet from your phone to your netbook in another way
You can't use wireless tether since your wifi adapter is broken, but maybe you could tether using bluetooth?
Debug your phone in another way
Maybe you could use an android application like aLogCat or similar?
But in the hand, sorry, you can't tether usb from phone to netbook while usb debugging from the netbook. Your success will depend on your ability to find an alternative solution.
I would like to point out that I am using PDANet for USB-tethered internet to type this reply while I am also debugging an android application on the same phone via Eclipse Juno. Not sure which side fixed this, but it is awesome!
As for why Eclipse isn't seeing your device, standard troubleshooting tips apply .. make sure to enable USB debugging and unknown sources/3rd party apps, try restarting, check usb drivers, update drivers/eclipse..
Device not detected in Eclipse when connected with USB cable
http://developer.android.com/tools/device.html
Eclipse not finding phone
PdaNet 3.5
Eclipse Juno Service Release 1; Build id: 20120920-0800
You can use bluetooth tethering to get internet connection and debug using USB.
Step 1. Turn off USB tethering
Step 2. Turn on Wireless USB Debugging
Connect to your device via USB
Enter "adb tcpip 5555"
Unplug your device
Look up your device's IP in the system settings
Enter "adb connect [ip address]:5555"
Step 3. Turn on USB tethering
Now you can use internet via USB cable and debug app in wireless mode
That's it!
Yes, its possible. There's a hack available at below links !
Source: HowToGeek , StackOverFlow
You can actually connect the adb to the phone via TCP. You may need a rooted phone for this to work, though
If I understand your question correctly, you want to tether your phone to the PC via USB, and use the (internet)connection of your PC + still get logcat output?
Then yes, this certainly is possible.Tethering is when your PC uses the internet of your phone, the other way around is called reverse tethering. Your device has to be rooted, then you can use this application for reverse tethering.
When you connect your phone to the computer via USB, you press 'connect' in the application. It then installs an app on your phone, which handles the reverse tethering connection. It works, I sometimes have to press 'check DNS' while it is connecting to make it working.. but it works! Also debugging via USB works the usual way.
First you need to debug your device using USB cable then type adb tcpip 5555 it will allow debugging via TCP/IP protocol.
After that turn on your USB tethering, now your computer get internet connection but lost the USB debugging.
Now you must know your phone IP address so you can debug via TCP/IP. You can use command arp -a in terminal and look at the gateway address.
The last is connect to your phone using adb connect yourphoneip:5555 for example adb connect 192.168.42.129:5555
Now you get debug and tether at the same time
You can use
WiFi Tethering - For Internet connection
Connect USB for adb.