I need remote ADB shell..
I know that we have to issue "ADB tcpip ".. to change ADB server to TCP listening mode.
But, the problem is that my phone is not rooted, and I do not have USB cable.
I can't issue tcpip command since I do not have USB cable,,
I can't change default.prop file as the phone is not rooted.
Is there any other ways to change ADB server to TCP listening mode???
I found an articel that says you can execute setprop persist.adb.tcp.port 5555 to make tcpip mode autostart after reboot.
The problem is, you must run this command as root.
On my device unfortunally the command su doeas not exist.
Here is the orginal Permanent network debugging on android
EDIT: I discovered, that the su command is only available when your device is rooted.
So the solution only works when you have a rooted phone
The simple answer is: no, you can't.
As you said, you can't access the prop file and don't have a cable to change with ADB. The only way is you find the port via an Android terminal emulator (a.k.a Termux)
For anyone looking for a better answer:
YES, YOU CAN!!
When you try to execute "adb tcpip 5555" without an USB cable, it returns:
"error: no devices/emulators found"
Emulators?? After googling I found the way and made a batch file that connects my device directly through WIFI, no cables needed at all:
set /p ip= Device IP:
:CONNECT
if "%CD%"=="C:\" goto ROOT
cd ..
goto CONNECT
:ROOT
cd ...Android\Sdk\emulator
echo.
echo Starting emulator...
start /MIN emulator -avd Nexus_5X_API_29_x86 -no-window
(you can check other avaliable devices with "emulator -list-avds")
cd ..
cd platform-tools
adb wait-for-device
echo.
echo Emulator started.
echo Connecting with device...
adb tcpip 5555
adb connect %ip%
echo.
echo Closing emulator...
(you need it just to be able to execute "adb tcpip 5555")
adb -s emulator-5554 emu kill
(you can check the name with "adb devices")
To enable wireless debug need to configure the ADB command. (in mac os)
Step1:- First of all need to enable adb command. (check SDK tool and install command-line tools)
Step2:- connect the device with a USB cable after that run the below command.
command: adb devices
the above command will show a list of connected mobiles.
Step3:- after that, we need to configure TCPIP protocol:
e.g : adb tcpip 5556
Step4:- Run command to connect the device.
command: adb connect your_ip:port_address
eg:- adb connect 192.168.1.152:5556
If you are using the stock android os system, then you can enable remote debugging in Settting -> developer options.
Related
I am trying to sideload a build to my phone, Alcatel Android 7. I have been able to sideload to it before but it's stopped working when I switched to a new network. I am running it from MacOS terminal.
Courtneys-MacBook-Pro-3:~ courtneytaniguchi$ adb connect 10.0.0.216
failed to connect to '10.0.0.216:5555': Connection refused
Courtneys-MacBook-Pro-3:~ courtneytaniguchi$
This phone is developer enabled, I have allowed installation of apps from unknown sources turned on in security, and USB debugging is on too. Yes, I am on the same network.
I had a similar problem failed to connect to '192.168.31.84:5555': Connection refused, final worked by:
kill and restart adb
adb kill-server
adb start-server
makesure USB wired connected
adb devices can see your device id
re-config to tcpip mode: adb tcpip 5555
Note: for multiple USB connected devices, should specify device serial id:
adb -s device_serial_id tcpip 5555
connect to you device via WiFi: adb connect your_android_phone_ip:5555
Full log for your refer:
adb kill-server
adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
adb devices
List of devices attached
2e2a0cb1 device
orga4pmzee4ts47t device
adb tcpip 5555
error: more than one device/emulator
adb -s 2e2a0cb1 tcpip 5555
restarting in TCP mode port: 5555
adb connect 192.168.31.84:5555
connected to 192.168.31.84:5555
Based on the commands you are entering it seems you are trying to do adb over wifi.
The following may help:
Rebooting the phone
Ensuring the phone is listening over TCP/IP by connecting to it via the USB and entering adb tcpip 5555
Turning USB debugging off and on again
I had the same error. Solved by following extra steps mentioned here which is connecting the device via USB and then executing the following command after finding device id :
./adb -s <device id> tcpip 5555
If you are stuck in the sideloading process, you can always e-mail the .apk file to yourself at an e-mail address which is configured on the phone, download the attachment, then go to 'downloads' app, and click on the .apk file, it should ask if you are sure you want to install the app, just say yes. You have to make sure that you have already selected 'Allow' in the Unknown Sources section in Settings/Development.
Same happened with me. Always rejected, I have two devices used to connect over wifi for some Android Project, im always rejected to 5555 on my Huawei Device. But there is one workaround i know that works.
➜ ~ adb connect 192.168.8.108:5555
failed to connect to '192.168.8.108:5555': Connection refused
➜ ~ adb connect 192.168.8.108:7612
connected to 192.168.8.108:7612
Try port 7612
Thanks!
I found several isntructions to activate ADB over wireless network instead USB connection (like this) but I have a problem: my device has the USB port broken.
I cannot execute adb tcpip 5555 because that, so I need to activate ADB over wireless if I want to use ADB to control the device.
Is there any way to do that without rooting the device? I tried several commands on a terminal emulator, but I didn't accomplish my objective.
Any proposal on that?
I have managed to do this using ssh with the following script. It might require some small adjustments (our platform is using systemctl, for one, so you might need to change those calls).
#/bin/bash
if ! command -v sshpass &> /dev/null
then
echo "sshpass could not be found. Please install it by running 'sudo apt install sshpass'"
exit
fi
IP="192.168.0.111"
USERNAME="user"
PASSWORD="password"
if [ $1 -a $1 == "disable" ]
then
read -n 1 -s -r -p "To disable adb over WiFi please plug in the USB cable and press any key."
adb disconnect $IP
adb kill-server
sshpass -p $PASSWORD ssh -o StrictHostKeyChecking=no $USERNAME#$IP "setprop service.adb.tcp.port -1; systemctl stop adbd; killall adbd &>/dev/null; systemctl start adbd &>/dev/null"
else
read -n 1 -s -r -p "To enable adb over WiFi please unplug USB cable and press any key."
adb kill-server &>/dev/null
sshpass -p $PASSWORD ssh -o StrictHostKeyChecking=no $USERNAME#$IP "setprop service.adb.tcp.port 5555; systemctl stop adbd; killall adbd; systemctl start adbd &>/dev/null"
adb kill- &>/dev/null
adb connect $IP &>/dev/null
fi
echo "Done!"
If your device is running Android 11 or above then you can accomplish this without initially needing to connect the phone to PC via USB as mentioned in the official Android developer site (link).
If the Android device is running Android 10 or below then there is no straightforward way without initially connecting USB (link).
Duplicate of
Run/install/debug Android applications over Wi-Fi?
Adding to it, if you install Android Studio Bumblebee version and your device OS is 11+,
there is a direct option to connect via Android Studio.
Here are the steps:
First, Connect your phone and machine on the same wifi network
on Phone:
Go to Developer Options -> Wireless Debugging -> Turn on the switch then tap on text Wireless Debugging
Select Pair device with QR code
on Desktop:
1.
Expand this drop down
Select Pair
Scan the QR code wait for some time and that's it!
Note: It disconnects frequently, has to be a bug which we should wait to get fixed
ADB is installed in the computer, and usb debugging is enabled on devices. Also I have connected one device over wifi successfully. How to connect more devices without having to mention the serial number of the device for every additional device with the -s flag like: adb -s <serial> tcpip <port>
Yes there is a way to do so without having to type the serial number.
Say you have 2 devices A (IP: 192.168.1.32) and B (IP: 192.168.1.33) that you want to connect to ADB over wifi:
Connect device A with a USB cable to the computer (but not B)
adb -d tcpip 5555
adb connect 192.168.1.32
Disconnect device A, and connect device B with a USB cable to the computer
adb -d tcpip 5555
adb connect 192.168.1.33
A slight change in the Abdul Wasae answer, based on my experience .
devices A (IP: 192.168.1.32)
devices B (IP: 192.168.1.33)
Connect device A with a USB cable to the computer (but not B)
adb -d tcpip 5555
adb connect 192.168.1.32
Disconnect device A, and connect device B with a USB cable to the
computer,This time you need to change the port !!
adb -d tcpip 5554
Here you need to specify port as well
adb connect 192.168.1.33:5554
I also have documented this here in more detail
Connecting multiple devices over wifi using adb
I have this problem long time ago so I decided to create this simple bash script.
Assuming that you already added the adb to the path:
export PATH=${PATH}:/home/YOUR-USERNAME/path/to/adb
You just need to follow this steps:
Run this commands: to create your script (typically, you want $HOME/bin for storing your own scripts)
cd ~
mkdir bin
cd bin
touch adb_connect
Open and copy the script using any editor like gedit.
gedit adb_connect
And make your file executable.
sudo chmod +x adb_connect
Modify your path to add the directory where your script is located:
export PATH=$PATH:$HOME/bin
Finally, now connect your device using USB and run the script:
adb_connect
Your device must be connect now, disconnect the USB cable and repeat steps 5 and 6 to add more devices. If a successful connection occurs, it will have this output:
Connecting to LGV498bdcb2c5
restarting in TCP mode port: 7105
connected to 192.168.20.105:7105
I used to be able to setup wireless ADB no problem (plug in, adb tcpip 5555, adb connect ), now it gets stuck indefinitely during the "adb tcpip 5555" command. Wired adb still works fine, so does setting up wireless ADB through apps in play store, just not via cmd. Between wireless working and now not working, I did a bunch of things so any of them may or may not be the problem:
1) Reformatted computer (Same OS)
2) Redownloaded the SDK needed for Android Development
3) Went from ParanoidAndroid to GPE on my HTC One.
Anyone have any idea what the problem is?
You can emulate what apps do with these steps on your device with root and android terminal emulator:
$ adbd stop
$ setprop service.adb.tcp.port 5555
$ adbd start
Then use adb connect XXX.XXX.XXX.XXX where XXX.XXX.XXX.XXX is your ip address found from:
$ ifconfig wlan0 | awk '/inet addr/ {print $2}' | cut -d: -f2
You can check if your connection is establed using netstat | grep 5555. You should see a tcp entry with your ip address and port for adb connectivity.
If your device is rooted then it is very simple to establish a wireless connection, you don't even need a USB cable. Download this app from Google Play https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb&hl=en
It worked for me at least, and as can be seen from the app rating it works for almost all.
-----Enter the command adb kill-server at command prompt-----
C:>adb kill-server
-----Enter the command adb devices-----
C:>adb devices
List of devices attached
daemon not running; starting now at tcp:5037
daemon started successfully
DeviceID device
-----DeviceID is the unique ID of connected device-----
-----Enter the command adb tcpip 5555-----
C:>adb tcpip 5555
restarting in TCP mode port: 5555
-----will see the response as given above -----
-----Enter the command adb connect 1.1.2.2-----
-----1.1.2.2 is the mobile device IP-----
C:>adb connect 1.1.2.2
connected to 1.1.2.2:5555
-----will see the response as given above -----
-----Now u can use 1.1.2.2:5555 ID as wireless to connect device-----
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.