Android: Adb rejected connection to client

2020-02-10 17:57发布

问题:

I was trying to install an app on my nexus 5 from intellij and for the first time i get an error saying

"DeviceMonitor: Adb rejected connection to client '5081': closed" 

I tried restart my adb restart computer, disable, enable android debugging sync gradle. The weird thing is that when i try running it on a virtual device it works. Anyone has an idea? Here is the full error code :

DeviceMonitor: Adb rejected connection to client '5081': closed DeviceMonitor: Adb rejected connection to client '5064': closed DeviceMonitor: Adb rejected connection to client '4962': closed DeviceMonitor: Adb rejected connection to client '5081': closed DeviceMonitor: Adb rejected connection to client '5064': closed DeviceMonitor: Adb rejected connection to client '5064': closed DeviceMonitor: Adb rejected connection to client '3483': closed DeviceMonitor: Adb rejected connection to client '3483': closed

logcat shows nothing, i tried running it in terminal "adb logcat" and it showed normal either.

回答1:

I just had this issue, and Googling didn't yield a ton of results when I looked it up. Alchete's answer was what solved this issue for me, but being new to the Windows command line, I didn't know how to execute it. So I just want to elaborate in case anyone is in the same boat as I was.

Open the Start Menu and type cmd to get to the command line.

Change directories to get to the sdk folder that contains the adb.exe file.

For me the command looked like this:

cd Documents\Programming\android-studio\sdk\platform-tools

Adjust based on the path to your sdk folder.

Then, you can enter:

adb kill-server

Followed by:

adb start-server 


回答2:

I just had this problem as well. Closing and re-launching Android Studio had no effect.

The solution for me was to execute the following commands in a terminal window:

adb kill-server

adb start-server

After that, my Android device connected as normal.



回答3:

I had the same problem recently.

I had moved the intent-filter tag in the AndroidManifest.xml file inorder to start a different activity.

What I had forgotten to do was change the run/debug target inside Android Studio. Click Run -> Edit configurations. Look at Launch string and check it matches the activity in AndroidManifest which has the launch XML inside it:

Launch XML:

<intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>


回答4:

My reputation is not high enough, but I wanted to respond to say that Alex Lowe's and Alchete's answer worked for me, combined with andy boot's answer. (+1 to Alex Lowe for the detailed response).

Furthermore, restart your Android Studio session once you have killed the adb. The server should start right back up again.

If, like me, you are getting this error because you may have changed intent filters around in your Android Manifest, i.e. you created a Splash Screen and added the Category_Launcher intent

For example, CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level application

..then you will want to make sure it is specified as your Launch Activity as previously explained (Run - Edit Configurations - Launch). "Launch default activity will initially be selected, but you want to change that to the new Activity you have specified as your Launcher.

Hopefully one of those two solutions will work!

Also, if you are having trouble finding the directory path for your Android SDK, go to your SDK Manager in Android Studio and the directory path should be at the top of the dialog box.



回答5:

I had the same problem which in my case was due to having erroneously selected wear instead of app (and the watch feature was optional, see e.g. android studio error : missing feature: WATCH for details). The GUI was stuck in "waiting for phone" forever.