Any way to reconnect adb connection without unplug usb line - android

Is there any way to make a phone whose status is offline to online without replug the usb line?

Just copy an paste in notepad with a .bat extension.
Before that make sure your adb.exe is included in system path or alternatively replace the 'adb' with path to adb.exe, For example:
C:\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb kill-server
#echo off
adb kill-server
adb start-server
adb devices
cls
echo "Android Debug Bridge Restated!!!"
pause

Disable and enable again USB debugging on the phone. Works most of the time. You can also try restarting the adb server on the desktop machine.

There's an 'adb reconnect' subcommand I hadn't noticed before today: it might only be in the newer versions of adb.
There's also a device-side version, but I don't quite see how the local machine can tell the device to do that without already being connected, so perhaps that's something you can execute in a device-side shell.

Related

How to restart android adb using terminal on macOS?

I keep having an issue with the Android Studio ADB not recognizing my devices. So far, the only solution I've found is to do a complete reboot of my entire computer, which isn't practical. I'd like to be able to restart the ADB from terminal, because I have seen other posts on here that claim it will fix the issue. However, I can't figure out where to use the commands "adb kill-server", because doing it at the base directory returns a "command not recognized". Can somebody help me figure out how to navigate into Android from terminal and use the command? Or, does anybody have another solution to the original problem of Android Studio not recognizing my devices?
Thanks in advance! Sorry for the wordiness.
blackbelt:~ blackbelt$ adb kill-server
blackbelt:~ blackbelt$ adb start-server
works on Linux as well as on Mac. In my machine, adb is in PATH
"command not recognized". Can somebody help me figure out how to
navigate into Android from terminal and use the command? Or, does
anybody have another solution to the original problem of Android
Studio not recognizing my devices?
In your case adb is not declared in PATH. You can either export the PATH, or specify the full qualified path to adb in the command line. E.g.
blackbelt:~ blackbelt$ /path/to/platform-tools/adb kill-server
blackbelt:~ blackbelt$ /path/to/platform-tools/adb start-server
or
blackbelt:~ blackbelt$ ./adb kill-server
blackbelt:~ blackbelt$ ./adb start-server
if you are inside platform-tools
Well instead of doing it through command line, if you find that hard you can also do the same from android studio.
Go to tools -> Android -> Android device monitor . Then it will open the separate window where you can see all the devices or emulator attached to the process. On the left hand side below the Devices tab there will be and menu bar, you need to click on the drop down arrow which will give you the option to reset the adb. Here is the image for reference
If you are using windows try to update the device driver for your device make sure the adb is correctly installed. When you connect your device to system see if it is allowed to be used at the system.
if adb kill-server not responding. Find the process id (PID) by typing top in terminal and finding PID next to adb. Then type kill <PID>
For example, for me PID for adb was 70163. Then i typed kill 70163
Simply stop adb:
adb kill-server
Then you can start it again any time:
adb start-server

Can't find my device with adb

I'm running adb on ubuntu, and my app (that I'd like to test) on a Galaxy S3. Got my S3 in debugging mode, I've edited /lib/udev/rules.d/51.android and .android files, restarted adb, and my laptop, but no luck. Any ideas what I might be doing wrong?
Try this on command prompt:
sudo -s
adb kill-server
adb start-server
Some more things you can try as I often find this helpful.
Check the Data Card, it might have problem.
Plug the data card to another port on the system.

Restart android machine

we have android + linux m/c, we log in into linux shell and boot the machine in android GUI.
now we have the some script that is running on the same machine through linux shell. In that case when the script hangs we need to restart android machine. but it result into restarting the linux machine too. as they are on same machine. so i need the way to restart the android so it comes out of hang state and control remains on the script that is running through the linux shell.
so is there any adb or linux command that work for me?
Have you tried simply 'reboot' with adb?
adb reboot
Also you can run complete shell scripts (e.g. to reboot your emulator) via adb:
adb shell <command>
The official docs can be found here.
You can reboot the device by sending the following broadcast:
$ adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
adb reboot should not reboot your linux box.
But in any case, you can redirect the command to a specific adb device using adb -s <device_id> command , where
Device ID can be obtained from the command adb devices
command in this case is reboot
I think the only way to do this is to run another machine in parallel and use that machine to issue commands to your android box similar to how you would with a phone. If you have issues with the IP changing you can reserve an ip on your router and have the machine grab that one instead of asking the routers DHCP for one. This way you can ping the machine and figure out if it's done rebooting to continue the script.

Insufficient permission when running 'adb shell'

I am on Ubuntu 12.04. And I need to use 'adb shell' to connect to my device on linux:
I get Insufficient permission when running 'adb shell'as myself.
But when I run it as 'root', it works.
How can I fix 'adb shell' so that I don' need to run it as root everytime?
I guess, the problem and solution are the same as in question "adb devices command not working".
In short: you must inform Ubuntu that android device, connected to USB can be used by unprivileged users (that's forbidden by default).
That's even decribed in official Android Developer's Guide: Configuring USB Access, but I prefer a bit simplier 51-android.rules file.
Can You try changing the owner of the file adb ?
sudo chown <usergroup>.<username> adb
This is may work for you!

How do you connect your terminal with the Android emulator

I have tried the navigate to the android tool folder and entering the "adb shell" command but it doesn't seem to work. My terminal seems only to recognize the adb part of the command and gives me an error message. What am I doing wrong???
List all connected devices by typing adb devices
Check, if there are any devices listed. If not you may want to check that your device is connected and/or your emulator is running.
If it works and you have for example your emulator running and your usb-device connected use:
adb shell if you only have device connected.
adb -d shell to connect to an USB-Device.
adb -e shell to connect to an emulated device.
If you have more than one emulator or usb devices you might want to use:
adb -s <DEVICE> shell
Note:
Make sure that the path to the android-sdk is properly set-up in your environment. To quickcheck, fire up a shell and type adb version. If that command succeeds, you're set up. If not, add /path/to/android-sdk/tools and /path/to/android/platform-tools to your $PATH env variable. On windows the android sdk is typically located in C:\Users\<username>\AppData\Local\Android\sdk.

Categories

Resources