How to ADB USB Debugging Mode without USB Cable - android

The USB cable interface of my phone is slightly broken, only supporting charging now. I cannot connect it to the PC to share files over MTP or USB Dedubugging with ADB.
Because USB Dedebugging is not working, I cannot uninstall some system apps with PC-side command "adb pm uninstsall --user 0 package_names". Is there other ways to uninstall them without connecting to PC (not rooted device).
I also tried to install JuiceSSH in the phone, and suppose to run "pm uninstall ..", but the command failed for not authorized. I am not sure whether only ADB USB Debugging mode can allow users to execute that command correctly?
My main goal is just to uninstall those system apps on the un-rooted device. I am pretty sure that ADB mode should work if my USB cable was not broken. Are there alternative ways to archive this goal (e.g. to enable ADB shell bypass USB cable, or some command in JuiceSSH to allow me to execute "pm uninstall --user 0 ..")?

sadly, no, without root you can't execute this command. if you could then any app could uninstall any other, thats very insecure for user
you have to connect to your PC at least once for enabling ADB wireless connection (check out how)
starting Android 11 there is and ADB Wireless debug mode built-in, it doesn't need any cable connection, even initial. but still limited to currently newest OS version...

Related

Is there a way to disconnect USB device from ADB?

I have a lot of scripts that use ADB to debug Android applications via Wi-Fi with emulators. The problem appears when I charge my Android phone via USB from my computer: ADB sees it and sends commands to my phone instead of emulator.
Is there a way to disconnect ADB from phone that charges via USB? I know I can send commands to emulators only via -e switch, as well as send them to specific device via -s switch. However, it is not OK for me, because I have to rewrite a lot of scripts to add more arguments if I want to implement this device selection feature. I don't need workarounds, I just curious does Google force ADB to debug any phone connected via USB that has USB debugging enabled in settings, or it is possible to remove specific USB connected phone from devices list on ADB side?
When I run adb disconnect, USB device remains connected.
USB connection for internal storage and adb connection for debugging are two separate things.
To disable adb - you can use adb disconnect or simply turn off usb debugging under developer options.
For disconnecting usb connection for internal storage certain ROMS have the option. e.g. CM 13 that i have at the moment allows connecting USB just for charging. Generally on other ROMS and Stock ROM I've not seen this option but you can try this. -> If you connect your device via USB while locked the internal storage will not be available unless you unlock the device once.
ADB doesn't support disconnecting a USB connection now(version 1.0.39).
"adb disconnect" can only disconnect a TCP connection set up by "adb connect", it can not disconnect a USB connection.
You can "disconnect" a connection by using push and reconnect commands as a workaround:
1.push a file to phone
adb -s SERIAL push somefile /data/local/tmp
2.reconnect while push is still in progress
adb -s SERIAL reconnect
SERIAL means serial number listed in the output of 'adb devices' command.
Repeat step 1 and 2, after a while, you can find this device is in offline state from output of "adb devices".
No adb command can operate this offline device until you kill-server and start-server.
just use adb kill-server to kill the connection
adb disconnect also works
On the device itself go to Developer options. There is a "USB debugging" switch. You can simply switch off "USB debugging" while you don't need the device to be seen by adb.
Alternatively (if, say, you want "Trust this device?" window appear on the device again) you can tap "Revoke USB debugging authorizations" option (also in Developer options. Tapping it will revoke all authorizations, including the one for your PC. Doing that will also restrict access from adb. To re-enable adb connection for the device, disable and re-enable the "USB debugging" switch. That will force "Trust this device?" window appear on the mobile device (should be unlocked for that perpose). Say "ok" and you should be able to connect via adb again.
Update your scripts to use the the id of the emulator so that you can direct adb commands to emulator:
adb -s{serial_number}
Ex:
adb -s emulator-5556 install myApp.apk
If you have only one emulator you can also use '-e' to direct adb commands to emulator.
adb -e install myApp.apk
The same can be done to force commands to your mobile, using '-d'.

Adb over wireless without usb cable at all for not rooted phones [duplicate]

This question already has answers here:
How can I connect to Android with ADB over TCP? [closed]
(37 answers)
Closed 5 years ago.
I want to debug Android APPs on my phone (LG nexus 4). I'm travelling and I forgot my USB cable. When I work at home I can do it just connecting the USB cable and executing the command 'adb tcpip 5555'. Then I can unplug the USB cable and connect via 'adb connect IP'.
But now I cannot execute the first command because I don't have a cable. I don't understand why I have to do it every time, since I already execute the 'adb tcpip' command before.
What I tried now:
I installed a terminal application on my Android and tried to execute that command there, but I received a "device not found" error. Maybe he cannot see himself...
I search for any reasonable option in "Android Development Options" and enabled everything seemed to have relation with Wifi. But nothing helped.
I search StackOverflow, but all answers I found involving connect via USB cable before. Is there I way to do this connection without the need of a cable at all?
Some info:
My Nexus 4 isn't rooted.
The android version is 5.1.1.
The question is about a non rooted device but if it is rooted the simplest way would be to:
From the terminal on your phone, do this:
su
setprop service.adb.tcp.port 5555
stop adbd
start adbd
See this answer for full details.
For your question
Adb over wireless without USB cable at all for not rooted phones.
Old Answer:
You need to connect your device to your computer via USB cable. Make sure USB debugging is working. You can check if it shows up when running adb devices.
Open cmd in ...\AppData\Local\Android\sdk\platform-tools
Step1: Run adb devices
Ex: C:\pathToSDK\platform-tools>adb devices
You can check if it shows up when running adb devices.
Step2: Run adb tcpip 5555
Ex: C:\pathToSDK\platform-tools>adb tcpip 5555
Disconnect your device (remove the USB cable).
Step3: Go to the Settings -> About phone -> Status to view the IP address of your phone.
Step4: Run adb connect <IP address of your device>:5555
Ex: C:\pathToSDK\platform-tools>adb connect 192.168.0.2
Step5: Run adb devices again, you should see your device.
Now you can execute adb commands or use your favorite IDE for android development - wireless!
Now you might ask, what do I have to do when I move into a different workspace and change WiFi networks? You do not have to repeat steps 1 to 3 (these set your phone into WiFi-debug mode). You do have to connect to your phone again by executing steps 4 to 6.
Unfortunately, the android phones lose the WiFi-debug mode when restarting. Thus, if your battery died, you have to start over. Otherwise, if you keep an eye on your battery and do not restart your phone, you can live without a cable for weeks!
See here for more
Ref: https://futurestud.io/tutorials/how-to-debug-your-android-app-over-wifi-without-root
UPDATE 1:
If you set C:\pathToSDK\platform-tools this path in Environment variables then there is no need to repeat all steps, you can simply use only Step 4 that's it, it will connect to your device.
To set a path:
My Computer-> Right click--> properties -> Advanced system settings -> Environment variables -> edit path in System variables -> paste the platform-tools path in variable value -> ok -> ok -> ok
UPDATE 2:
Go to the android terminal
adb tcpip 5555
adb connect your_ip_address
We can do it without a USB cable at all in the following ways.
NEW UPDATE 1: (Latest Answer without using USB cable at all)
Note: It will work only when your laptop and mobile should connect to the same WiFi.
Step 1: In Android studio choose "Pair Devices Using Wi-Fi" from the Device Connections dropdown.
Step 2: In Mobile go to settings and search for "Pair using QR code" and scan the QR code
NEW UPDATE 2: (Latest Answer without using USB cable at all)
Note: It will work only when your laptop and mobile should connect to the same WiFi.
Go to developer options from the mobile settings and enable Wireless Debugging
That's it!
Had same issue, however I'm using Macbook Pro (2016) which has USB-c only and I forgot my adapter at home.
Since unable to run adb at all on my development machine, I found a different approach.
Connecting phone with USB cable to another computer (in same WiFi) and enable run adb tcpip from there.
Master-machine : computer where development goes on, with only USB-C connectors
Slave-machine: another computer with USB and in same WiFi
Steps:
Connect the phone to a different computer (slave-machine)
Run adb usb && adb tcpip 5555 from there
On master machine
deko$: adb devices
List of devices attached
deko$: adb connect 10.0.20.153:5555
connected to 10.0.20.153:5555
Now Android Studio or Xamarin can install and run app on the phone
Sidenote:
I also tested Bluetooth tethering from the Phone to Master-machine and successfully connected to phone. Both Android Studio and Xamarin worked well, however the upload process, from Xamarin was taking long time. But it works.
This might help:
If the adb connection is ever lost:
Make sure that your host is still connected to the same Wi-Fi network your Android device is.
Reconnect by executing the "adb connect IP" step. (IP is obviously different when you change location.)
Or if that doesn't work, reset your adb host:
adb kill-server
and then start over from the beginning.
If usb is not working you should checkout debugging over bluetooth (Without Rooting)
http://zcourts.com/2013/07/19/android-debugging-over-bluetooth-without-root/#sthash.hVCLtWSk.dpbs
type in Windows cmd.exe
cd %userprofile%\.android
dir
copy adbkey.pub adb_keys
dir
copy the file adb_keys to your phone folder /data/misc/adb. Reboot the phone. RSA Key is now authorized.
from:
How to solve ADB device unauthorized in Android ADB host device?
now follow the instructions for adb connect, or use any app for preparing. i prefer ADB over WIFI Widget from Mehdy Bohlool, it works without root.
from:
How can I connect to Android with ADB over TCP?
Connect android phone without using USB cable except XIAOMI PHONES
== MAKE SURE THAT YOUR PHONE HAS USB DEBUGGING ENABLED ==
== IP Address series should NOT be '0' like 192.168.0.10
1. Connect your PC (Laptop) and Android phone to same wifi network.
2. Go to the Android SDK folder > platform-tools and open command prompt by holding the shift key and right clicking on the folder.
3. Type the command "adb tcpip 5555", and hit Enter, sometimes it gives an error but ignore it and go ahead.
4. Type "adb connect [YOUR PHONE IP]". example: "adb connect 192.168.1.34" and hit enter, your phone will be connected to PC.

Persist ADB over Wifi in android studio?

Hi i am using a MotoG2nd Generation updated to Android Lolliop,
Under Android adb Section from google's guide , it says
$ adb usb
restarting in USB mode
$ adb devices
List of devices attached
######## device
$ adb tcpip 5555
restarting in TCP mode port: 5555
$ adb connect #.#.#.#
connected to #.#.#.#:5555
$ adb devices
List of devices attached
#.#.#.#:5555 device
I followed these steps and ADB over WiFi works perfectly ,
However the problem is once i restart android studio or turn off and turn on my wifi in my device the connection is lost and ADB connect DEVICE IP command no longer works , i need to use the USB cable and walk through the entire process again , i would like adb to always listen to my phone in my Home Wifi network ,
Any other cons in using ADB over WiFi rather than USB , i find WiFi better cause the USB cable is sometimes flaky and Cables seem old fashioned considering the fact that most file transfers or other operations can be accomplished over LAN (WiFi) instead these days ,
Please help!
It works as it should be. The device will keep the adb daemon in TCP/IP mode until it is restarted or until you run the command adb usb, which restarts the adb daemon in USB mode. Connecting adb over WiFi is not guaranteed to work on all devices. Also, the communication performance with the device is much worse, which can be annoying when you need to deploy a large application.

USB connection issues

I am trying to run my android app in my samsung device GT-S6012. I use Windows 7 Home Basic. The driver is installed properly. As soon as I connect the mobile using USB cable, for some seconds "adb devices" shows my phone. But then I get a message USB connection error, windows is unable to detect the device and USB is malfunctioning.
I tried uninstalling/re-installing driver, but no luck. I tried Google on this topic but nothing solved my issue.. Can Anyone let me know how can I fix it
windows is unable to detect the device and USB is malfunctioning
Highly unlikely. Unless your USB connector in your Samsung device is broken, USB cable is dead, or USB port in your computer is not functioning. If it's not, you can enable ADB to work with your device by doing the following:
Install the Samsung Universal USB drivers for mobile devices (which I assume you have done already).
If ADB did not ACK/started. First, open a command prompt (since you use Windows) at \android-sdk\platform-tools\ directory and type adb kill-server to kill ADB. Then, type adb start-server to start ADB. Finally, type adb devices to see if ADB has recognised your devices.
See here for a list of ADB commands you can use with Android.

Android adb wireless debugging with USB accessory

I have adb wireless connection working for debuging applications in eclipse, but I am having an issue with an application that is using the USB cable to attach to an accessory.
The application is designed to start when the accessory is plugged in, SO I establish my ADB connenction and then run debug on eclipse, code loads etc.., now when I plug the accessory in the app starts and runs but loses communication to eclipse. So I can't debug!
In the command prompt just run adb connect <device ip>:5555 again after the tablet is plugged into the FT311 (I am assuming it is the FT311 from your other question). It will then reconnect and then run adb logcat again and done.
That is only a partial solution. Yes, you can reestablish the connection over WiFi (which works great, BTW) but the moment you disconnect or reconnect the USB cable, you'll lose the association with ADB again - even though it's running over WiFi and should have no dependency upon USB at all.
So beware, this works but will not solve the problem if, for example, you're trying to debug anything associated with USB attach/detach Intents.
USB host and accessory overview in Android official developer documentation here REMIND US OF THIS:
Debug considerations
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.
Remember:The Android official documentation will give you better basic understanding of the Android,not sometimes,but ALMOST everytime.

Categories

Resources