'setprop doesn't set the property on rooted Android phone
I'm developing an application (using Eclipse + Android SDk/NDK) which uses the micro-usb port on an android phone to connect to peripherals. I am trying to connect to the ADB daemon on the phone via WiFi (tcp port 5555) so I can debug my application in Eclipse. However, I just can't get this to work.
Nothing I try actually results in the ADB daemon on the phone switching to TCPIP mode (as far as I can tell by looking at the output of getprop). The issue seems to be that I can't set the relevant service.adb.tcp.port property on the phone. The development phone I am using is an LG GT540 running CyanogenMod 7.0.0 (Android v2.3.3). Development machine is iMac running OS X Lion.
Here is some relevant information on what I have tried/confirmed/discovered:
- The phone is rooted (
ru.secure = 0) - Connecting to ADB via USB works fine
- The adb service on the Mac is running as root (
adb root) adb shellgives me a shell with super-user access (# prompt, su, ability to edit system files etc)adb tcpip 5555does not complain or throw errors when run from a terminal window on the mac but does not set theservice.adb.tcp.portproperty on the phonesetprop service.adb.tcp.port 5555entered at the # prompt of a terminal window on the phone does not complain or throw errors but does not set theservice.adb.tcp.portpropertysetprop persist.service.adb.enable 0works from both Mac and phone shells (confirmed by checking ADB daemon stops andgetpropreturns 0 for the enable property)setprop persist.service.adb.enable 1works fine from both Mac and phone shells (confirmed by checking ADB daemon starts andgetpropreturns 1 for enable property)- The only properties on the phone relating to ADB on the phone are
persist.service.adb.enableandinit.svc.adbd(if ADB is running)(confirmed bygetprop | grep adbon the phone) - Apps on the market that purport to 'automatically' configure ADB for Wifi (such as WiFi ADB) do not work either (
tcp.portproperty is not set and ADB over TCP does not work)
Am I looking too hard here and missing something obvious? There are many posts and articles on the Internet relating to problems getting ADB to work over TCP but they all relate to phone rooting issues.
Is anyone able to shed some light on why I can't seem to set this particular property or suggest any other issue that may be preventing the ADB daemon from running in TCPIP mode?
Solution 1:[1]
You need to stop and then restart adbd on the phone for the tcp port property to take effect.
- setprop service.adb.tcp.port 5555
- stop adbd
- start adbd
Solution 2:[2]
With any device (rooted or not) it really ought to be as simple as:
- Connect to USB
- Run
adb tcpip <port>
You will see restarting in TCP mode port: <port> spit out the terminal if it worked. If you see nothing, it didn't.
The property is set for you by the daemon. Tutorials telling you to set the propery and reboot adbd are focused on code that needs to execute on-device (i.e. if you are writing an ADB over WiFi app).
However, you mentioned you are using Cyanogenmod. Doesn't CM have an "ADB over Network" setting in Developer Options (I swear it was there in CM7)? I know that their chosen port is 5555. You may be running into conflicts with that feature trying to do it manually. Probably best to use what's built into the system if it's there.
Solution 3:[3]
1 line to add on start of application.
setprop service.adb.tcp.port 5555 && stop adbd && start adbd
This resets adb on start!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ChuckB |
| Solution 2 | devunwired |
| Solution 3 | Tomek |
