ADB debugging not restarting on reboot - android

I am running lineageOS on a rooted firestick. I am using ADB on the Firestick to control it via Homeassistant. The problem is that the adb debugging does not automatically work on reboot. Everytime i reboot i have to manually go to the menu turn off the ADB debugging and then turn in back on. After doing this i am able to reconnect adb via network (i.e, on homeassistant).
I want to ask is there any way i can use a script to automatically do this on restart of firestick. I have tried creating a script in init.d with the following contents but it doesn't seem to work.
adb tcpip 5555
I have added the following line to build.prop but this doesn't seem to work too
service.adb.tcp.port=5555
On restart the adb debugging is on in the developer tools but somehow it doesn't connect (either to Homeassistant or to my laptop), what seems to make it work is toggling it off and then back on.

Related

Is there a way to build and run an Android Studio app on a phone remotely?

I am developing an app for Android that controls a robot using the FTC SDK, and I need to be able to make small changes to motor values in the code and re-install it to test the new code. My problem is that I need to do this a lot of times, and the system of taking the phone out of the mount (which takes a while) and plugging it into my computer to upload, waiting for it to upload, turning off the power to the robot, plugging the phone back in to the robot, and turning the power back on has started slowing our progress down a lot. I was wondering if there was any way I could install the new code on the phone without taking it out of the mount.
Our phone is connected to a usb hub with a webcam and the hardware controller, so I was wondering if attaching a wireless usb transmitter to the hub and my computer would still let the phone show up on the android studio connections manager and let me install it.
So if anyone has done this before, or knows about any way to make this work, thank you for the help!
Yes. First make sure that the robot phone has developer mode and USB debug enabled.
(Do this by going to settings -> software info and click on build number ten times, then go settings -> developer options and enable USB Debug)
Then, go into the robot controller phone and under the three dots at the top right select program and manage. Connect your computer to the shown internet name and password.
Next if you are on Windows plug in the phone and run the following code in command prompt,
pushd "%userprofile%\AppData\Local\Android\sdk\platform-tools"
adb disconnect
adb tcpip 5555
adb connect 192.168.49.1
popd
PAUSE
If you are on Mac plug in the device and run the following code in terminal,
cd ~/Library/Android/sdk/platform-tools
./adb disconnect
./adb tcpip 5555
./adb connect 192.168.49.1:5555
Finally, disconnect the phone, go back to android studio and happy wireless coding.

Pair computer and phone with USB cable once, and then always use ADB over WiFi, even after reboot

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.

Android ADB can't ALWAYS see the phone device

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.

ADB TCPIP Connecting trouble

I have two Galaxy S3. One of them is rooted and the other one is not. So, when I tried to connect them over the local network, computer can see the rooted one. But normal one stucks on the tcpip step. So, I write
adb tcpip 5555
It says
restarting in TCP mode port : 5555
but nothing else. Can you help me with these?
Note: My OS is Win8.
After running
adb tcpip 5555
What is the ouput when you try to run the "connect" command to the devices based on knowing the IP of the phone e.g.
adb connect 192.168.1.186
should result in something like:
connected to 192.168.1.186:5555
Also, make sure you have USB debugging turned on on the Samsung 'Settings' --> 'Developer options'
(If you don't see 'Developer Options', you'll need to enable it first (link))
I have made a small script for myself
Simply Connect your device (in USB debugging mode).
Go to location "C:\Users\PC\AppData\Local\Android\sdk\platform-tools"
Press Shift + Right Click --> open Command window here.
Paste that script there , make sure adb.exe is available at that path in PC.
run wireless.bat follow steps give your IP that's it.
wireless.bat

Disconnect network in Android emulator while keeping ADB alive

I have made a mistake somewhere in my code that my Android app crashes when I switch off the network in the emulator while the app's HTTPClient is making some request.
But I cannot debug it, because when I switched off the network, I also lost the ADB connection. Thus I cannot see what exception is causing the crash.
I have tried switching off the network by:
F8
Set 'Data' to 'Unregistered' or 'Denied' in DDMS Emulator Control
I can put my Mac offline and ADB will stay up, but unfortunately I cannot reproduce the crash that way.
Is there a way to turn off network in the emulator, while keeping ADB alive? I basically need access to the LogCat entries.
Thanks!
You can run logcat from the device instead of from ADB and redirect it to a file for offline reading.
adb shell logcat [-v threadtime] > /sdcard/mylogs/logcat.log
Instead of
adb logcat [-v threadtime]
Then you can get the file when you reconnect to the device.
On linux this is pretty simple with iptables firewall. I suppose you trying to debug api calls so just block api host:
iptables -I OUTPUT -d api.example.com -j DROP
Sure you can do the same thing with Mac or Windows firewall.
You could always put the device into airplane mode, that will still allow you to connect over adb but not give the emulator a connection to the internet. You can also turn off data through eclipse via the emulator control section in ddms by putting in unregistered/denied to the data drop down.
I know this is old question but someone might use find for this.
My setup
Eclipse Kepler with emulated android 4.4
If you want to keep your adb alive and network turned off, you can try this.
Start emulated device
Activate flight/airplane mode
Restart Eclipse
It should work! Check DDMS perspective for attached devices or use adb devices command

Categories

Resources