Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
638 views
in Technique[技术] by (71.8m points)

android - Changing default port (i.e. 5037) on which adb server runs

I am a budding android developer and if there is no easy way of configuring the adb server to run on another port then the inflexibility of the tools will force me to quit android app development.

A web search did not return any solutions.

I also searched for '5037' in all files in android sdk directory but did not find a setting there.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the environment variable ANDROID_ADB_SERVER_PORT to select the port.

The following works under bash:

$ export ANDROID_ADB_SERVER_PORT=12345 
$ adb start-server
* daemon not running. starting it now on port 12345 *
* daemon started successfully *
$ adb devices
List of devices attached 
TA2070M5O6  device
$ ANDROID_ADB_SERVER_PORT=6789 adb devices
* daemon not running. starting it now on port 6789 *
* daemon started successfully *
List of devices attached 

In another terminal I ran:

$ ANDROID_ADB_SERVER_PORT=6789 emulator ...

Back to original terminal:

$ ANDROID_ADB_SERVER_PORT=6789 adb devices
List of devices attached 
emulator-5554   device
$ adb devices # ANDROID_ADB_SERVER_PORT was exported as 12345
List of devices attached 
TA2070M5O6  device

I found this via the Jenkins Android Emulator Plugin as I noticed it was running adb on a different port.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...