How to get adb logs via bluetooth? - android

How to get adb logs via bluetooth?
need to connect an android device to my laptop to get the adb logs, but through usb cable its not working.

Dude, you don't need Bluetooth to do so, you can get ADB logs via Wi-Fi.
The steps:
Connect your device to your laptop via USB (yes, you've read right, if your USB cable is not working, you can use an alternative USB cable temporarily or borrow one from your friends).
Type adb tcpip 5555 in the terminal
Type adb connect XXX.XXX.X.X (the X's represent the local IP address of your mobile device, if you don't know your device's IP, go to Settings > Wi-Fi > Advanced).
You can disconnect your device from your laptop and now you can debug your apps wirelessly.
If you really need Bluetooth to use ADB. Bad news! That's not even possible.

Related

How to connect ADB over wifi network without usb cable?

I want to connect my adb to real-time android, not to emulator but it gives an error: "cannot connect to 192.168.10.4:5555: No connection could be made because the target machine actively refused it. (10061)"
I tried this command: adb connect
It is possible starting with Android 11. On the phone click Pair device with pairing code, then on the dev machine do the following:
cd myandroidsdk/platform-tools
adb pair ipaddr:port
Take ipaddr and port from your phone. The terminal will then prompt you to put in the pairing code.
https://developer.android.com/studio/command-line/adb#connect-to-a-device-over-wi-fi-android-11+
In latest updates of Android Studio, you can easily pair your device wirelessly
Go to Device Manager > Physical > Pair using Wi-Fi
Then go to your phone's settings Developer options > Wireless debugging > Pair using QR code
Your phone will be connected to Android Studio after scanning the QR code
Note: this feature works on Android 11+ devices
Old Devices
Make sure your phone and laptop are connected to the same router
connect your phone to your laptop with usb cable
open a terminal window
adb devices
shell response should be something like this:
List of devices attached E1MGAP2810904770 device
adb tcpip 5556
adb connect 192.168.1.47:5556
shell response should be something like this:
connected to 192.168.1.47:5556
change the 192.168.1.47 with your local IP address.
you can find your phone's IP Address in Settings -> Status ...
Please follow the below link to get the detailed answer :
https://developer.android.com/studio/run/device
And one more think , don't connect your mobile with charger while connecting the android studio to mobile without usb cable.
Connect to DNS Server IPv4 address instead of just IPv4 address. Check in your wireless properties.

Unpluging usb cable also disconnects wireless adb connection [duplicate]

I develop on my tablet using android studio.
The tablet is connected to the computer by wifi using
adb connect <ip_andress>:5555
My application contains listeners for USB devices attached/detached.
But unfourtunately, when I connect/disconnect usb device to/from the tablet, the adb connection is getting killed, and I can no longer see the device under "adb devices".
It is not a adb-connection-by-wifi what gets killed. It is just that USB enumerations affect the sys.usb.* system properties which on many devices is causing restart of adbd regardless whether it's being used over USB or tcpip.
Do grep "stop adbd" /init*rc to see what I mean.
You could either comment out those stop adbd lines or just disconnect the USB cable before running your adb connect command.
I was never able to connect my cellphone with my computar through wi-fi.
I had already given up. I followed all the instructions and tips, and nothing worked.
Finally, I did what no one said to do.
I've connected the phone to the WiFi network provided by the cable modem itself and not to some (not all) additional networks that are included in the router.
At home I use one of these networks, because I use a Deco Tp-Link router, which propagates the signal to my entire house, but this network is NOT compatible with ADB. It does not identify it as belonging to the same network.
After this, I use the normal procedure described here.
a) Connect cellphone with a USB cable
b) Find the IP_Phone depends on system in the cell phone. Here I use Settings, About Phone, Status and IP address.
c) Run the following adb commands in Command Prompt (Windows) or Terminal (Linux), where IP_Phone is the IP above mentioned. Normally adb.exe is an executable stored in computer path. adb is already included in Android Studio package.
adb tcpip 5555
adb connect IP_Phone
d) Now disconnect USB cable and it's ready. The cellphone model continues to appear in the status line in the top of Android Studio.
-/-
The best wifi is that defined in Cable Modem. It, unlike an any account defined in my router, answers to a ping command.
ping IP_Phone
Disconnect the usb cable just before running adb connect <*ip_address_of_your_phone*>

adb wifi often go offline, how to keep adb online?

I'm using Android tablet communicating with a USB device through USB port, the tablet only has one usb port, so I use adb wifi as my debug tool. However, when I connect adb through WIFI, the connection won't keep long(only a few minutes us usually), how to keep the adb wifi connection online all the time?
Another question, is it possible to use USB HUB to connect the tablet with both USB flash-drive and my computer, and keep adb running?
Many thanks!!!
After lots of unsuccessful attempts,I have noticed that turning Allow ADB debugging in charge only mode specification on , solved the problem . It makes the device online and accessable over wifi to ADB.
You can find it under Developer options section.
Here is what I found out from researching everywhere and developing on my own for more than a week.
Q1. adb service often crashes if it is not doing any executions for a long long time.
A1. calling adb commands time to time keeps adb server online.
Q2. wifi connected device sometimes disconnect.
A2. Before you check your wifi on the connected device, check the wifi that your ADB server is running on. Ping to google and if it is well connected, ping to the device.
Wireless can disconnect on its own and even wired connection is sometimes disconnected. so calling "adb connect ..." when the device is not already connected is necessary. You could do this easily by saving "adb devices > device.txt" and query out whether your expected wifi is on the list. If not, connect again..(do this in another thread).
Q3. wifi connected device is sometimes offline.
A3. This is because by TCP/IP connection your ADB server is now on Time_Wait stance. The last connection was interrupted that the next connection is now offline because the last connection is not completely shut down. You can either manually disconnect/connect your device's wifi or restart TCPIP connection by ex) "adb tcpip 5555"
If you want to do this automatically, you are going to have to disconnect/connect your device's wifi programmatically.
Leave any other questions and I can answer on the comments.
When connection is lost and adb devices shows device is offline, like this:
prompt> adb devices
List of devices attached
192.168.1.1:5555 offline
then adb disconnect IP followed by adb connect IP will often work:
prompt> adb disconnect 192.168.1.1
disconnected 192.168.1.1
prompt> adb devices
List of devices attached
prompt> adb connect 192.168.1.1
connected to 192.168.1.1
prompt> adb devices
List of devices attached
192.168.1.1:5555 device
Use adb over wi-fi without any third-party apps. Follow the steps.
Connect device via USB
Open your terminal and check your device is listed with adb devices command
Type adb tcpip 5555 and enter (or use another port instead of 5555)
Plug out your USB cable. You don't need it anymore.
Take your Android phone and go Settings/About/Status
Check the IP address part. Let's say your IP address is 192.168.x.y
In your terminal, write the command adb connect 192.168.x.y
Now, you have connected your device via wi-fi.
You can see your device in adb devices
Enjoy it! :)
This seems like an issue with your wifi. As a precaution, just keep the terminal open and whenever you need to test just press the 'UP arrow' key to get to previously ran adb connect "<ip>" command.
I tried many ways but this one worked out for me:
force the display on and of in a loop would keep the device online
adb shell input keyevent 224
timeout 2
adb shell input keyevent 26
timeout 58
this turns the display on every minute for 2 seconds
So, I'm using Scrcpy and Adb to wirelessly connect to my Phone(for developing Flutter Apps) and since the screen wasn't staying awake even by Scrcpy --stay-awake command.
I had to change Lock Settings=>Lock Screen => Sleep, and settings to Never Sleep.

How to use adb using bluetooth?

I am currently using an API 18 (Jelly Bean) device, and it does not support ADB over Bluetooth by default (No option available in developers option for wireless debugging) I have to connect my device with my Laptop using Bluetooth Personal Area Network which is Bluetooth tethering of my phone. Can anyone help me with starting a TCP open port my phone so that I can connect ADB using the adb tcpip "open_port_no" and adb connect <phone_ip_address>:open_port_no commands?
I have already tried some apps from playstore to do so but they all failed.
You need to enable the TCP port first by connecting a USB cable to your phone and setting it from the console on your PC/Mac:
adb tcpip 4455
Now turn on the Bluetooth on your phone and enable tethering.
You need to use the IP address of your phone. It will most likely be 192.168.44.1 since this is the default. If not:
You can get this using a few methods depending on your computer type:
ifconfig
ipconfig /all
route | grep default
Then connect to your phone from your computer using:
adb connect 192.168.44.1:4455
You should get a response:
connected to 192.168.44.1:5555
This works perfectly for me. Sorry for the late response :) I was just looking for the same thing and happened upon the solution. Sharing is caring.

Android Host Mode USB debugging

I am developing an application where my android phone connects to a USB accessory. However, when the accessory is connected is there any easy way to debug the application?
Can we use a micro usb hub or similar device?
When debugging applications that use USB accessory or host features, you most likely will have USB hardware connected to your Android-powered device. This will prevent you from having an adb connection to the Android-powered device via USB. You can still access adb over a network connection. To enable adb over a network connection:
Connect the Android-powered device via USB to your computer.
From your SDK platform-tools/ directory, enter adb tcpip 5555 at the command prompt.
Enter adb connect <device-ip-address>:5555 You should now be connected to the Android- powered device and can issue the usual adb commands like adb logcat.
To set your device to listen on USB, enter adb usb.
source: Android developer site
You could write an app that reads the logcat output on the phone and displays it on the screen and/or saves it to a file which you can pull with adb afterwards.
The app must be given READ_LOGS permission, which you can do with adb shell pm grant com.package.appname android.permission.READ_LOGS (at least on a rooted phone).
Another alternative might be to log over WiFi. adb has an option to connect over TCP/IP, but this is not something I've tried so I don't know how difficult it is to set up or how well it works.
Unless your logs are really verbose it's sometimes enough to run through your USB accessory use-case and then unplug the accessory and connect the phone to your computer to catch the logcat output. The logs are buffered up to a certain amount, so you can get a reasonable amount of logs using this method.
You could run an Android image in Virtualbox. This would allow you to connect your USB device to the virtual device, and debug over the bridged network connection.
I haven't figured out how to convert the SDK .img OS images to VDIs for use in Virtualbox, but there are plenty of canned VDIs out there.

Categories

Resources