-3

I connect Samsung device via USB to my laptop. When I run the command adb start-server from AndroidStudio/Java project, It doesn't work. The same command works from terminal:

program output:

I/System.out: adb start-server
I/System.out: cannot bind tcp:5038
I/System.out: daemon not running. starting it now on port 5038
I/System.out: exit: 255

Similar thing happends when I run adb -d devices -l command:

I/System.out: adb -d devices -l
I/System.out: cannot bind tcp:5038
I/System.out: daemon not running. starting it now on port 5038
I/System.out: exit: 1

Terminal output:

C:\Users...\Android\Sdk\platform-tools^adb start-server 
C:\Users...\Android\Sdk\platform-tools^
C:\Users...\Android\Sdk\platform-tools^adb -d devices -l
List of devices attached
df346805               device product:j53gxx model:SM_J500H device:j53g 
C:\Users...\Android\Sdk\platform-tools^

The relevant Java command:

Process proc = Runtime.getRuntime().exec("adb start-server");
Udi M.
  • 1
  • 1
  • 5
  • once try adb kill-server and then adb start-server. – coder Nov 30 '17 at 10:11
  • How did you know that ADB is not started? After last update of Adnrdoid studio "adb start-server" command do not print * daemon not running. starting it now on port 5037 * and * daemon started successfully * – Dimon Nov 30 '17 at 10:29
  • The default port usually is 5037. Have you changed it? – Dimon Nov 30 '17 at 11:00
  • Try to run on different port's number. Command to run adb server on different port >$ adb -P 12345 start-server – Dimon Nov 30 '17 at 11:03
  • @Dimon I don't know why, but my default port is 5038. But when I run adb -P 5037 start-server it gives me the same result: //adb start-server //cannot bind tcp:5037 //daemon not running. starting it now on port 5037 //exit: 255. kill-server works, however. – Udi M. Dec 04 '17 at 04:24
  • I tried to run the application on different target, but got poor results: `Exception: Working Directory:null Environment:null` – Udi M. Dec 11 '17 at 11:54

2 Answers2

0

These steps may help,

  1. Disconnect your phone
  2. Manually kill process(adb.exe) from Task Manager if exist.
  3. Apply <..sdk/platform-tools>adb kill-server in command prompt
  4. Apply adb start-server
Dhruv Patel
  • 1,529
  • 1
  • 18
  • 27
0

I read in the following answer - Error while executing adb command programmatically that we have to root the device - the device has to be in superuser root mode - in order to run adb start-server.

Udi M.
  • 1
  • 1
  • 5