35

I'd like to connect to android emulator on bluestacks 4 with adb. but I've got an error with adb.exe -s emulator-5554 shell

checking devices.

$ adb.exe devices
List of devices attached
BH901...      device
CB512...      unauthorized





emulator-5554   device

once I shutdown bluestacks window, the emulator-5554 will be hidden from above command's result. thus I think emulator-5554 means bluestacks.

then commnad as below to use adb.

$ adb.exe -s emulator-5554 shell
error: closed

but as you know, an error occured.

k23j4
  • 723
  • 2
  • 8
  • 15
  • Can you disconnect all devices, run `adb kill-server` then run your emulator and execute `adb devices` – Tom Dickson Jan 22 '19 at 23:08
  • @TomDickson I did. I got the same error `error: closed`. `deb devices` output is the same result as above as well. – k23j4 Jan 22 '19 at 23:38
  • Bluestacks is very buggy software; sometimes it works, sometimes it is not, and it is complex to say what is the reason. – Vitalii Apr 11 '19 at 07:39

5 Answers5

69

First, in Bluestacks, go to Settings -> Preferences -> Enable Android Debug Bridge (ADB). Like this:

enter image description here

At this point, Bluestacks enables its adb functionality and exposes itself to the localhost at port 5555 (the default port)

So, in your command line, type adb connect localhost:5555 and you should be good to go.

Jack
  • 5,354
  • 2
  • 29
  • 54
  • I can't see this option. http://prntscr.com/o583ya. I have installed Android Studio, Android USD Drivers etc. ADB work for android phones. But, for Bluestacks it not works. and i can't see the mentioned option. Any idea what is it? – Ameer Hamza Jun 22 '19 at 11:38
  • Same for me blueSTacks 4.32.75.1002, doesn't show the option – Youssef El Behi Aug 15 '19 at 22:36
  • It may be needed to restart BlueStacks after checking 'Enable ADB'. – m7913d Nov 22 '19 at 09:20
  • And restart adb server. – tk_ Feb 04 '20 at 16:14
  • I know I'm late to the party but for the record, I didn't have the option in Bluestacks until I installed android development tools. – Joffrey May 25 '21 at 22:38
7

I did exactly as the chosen approved answer but i still could not connect my android studio to Bluestack 4. Hence i think the problem both of us are encountering could be due to bluestack device ip has changed. (Even if you had detect the device using adb devices command earlier on). Each time i open up my bluestack emulator, i notice that its ip is always different. Hence that could be one of the reason why you could not add adb to bluestack4.

The following step works for me. I am using windows 10, Android Studio 4.0.1, Bluestacks 4.200.

  1. find your android studio sdk platform tool folder. For me its is custom installed in my D drive. for example-> D:\AppData\Local\Android\Sdk\platform-tools
  2. right click on adb.exe and run as administrator. (click on yes if a pop up ask if you would like to make changes to your devices. After that you would only see another pop up that suddenly disappear.)
  3. open Bluestacks. Run your selected emulator (samsung/pixel etc). Ensure that you have enable "Enable Android Debug Bridge (ADB) in the emulator preferences.
  4. open platform tools folder path: Click on address bar, alternatively press Alt + D. Now when address bar is highlighted, type cmd in the bar. Press Enter key.
  5. enter the following command->adb connect xxxxxxxxxxx where xxxxxx is your device localhost ip. (see attach pic. My device ip is 127.0.0.1:xxxxx hence my command is ->adb connect 127.0.0.1:xxxxx
  6. continue with the following command->adb devices
    you would see your bluestack emulator device. same ip listed.
  7. open your andriod studio. you would be able to see your bluestack emulator

[enter bluestack adb preferences1

android studio with bluestack emulator

devio
  • 607
  • 9
  • 29
4nn4bel
  • 135
  • 2
  • 8
3

And I have test bluestack 4 in windows 10 and enable the adb permission in bluestacks 4 settings. It works for me.

enter image description here

enter image description here

nooper
  • 691
  • 1
  • 9
  • 25
3
  1. After enabling adb in blue stack
  2. go to platform-tools folder

e.g. "C:\Users\Your Username\AppData\Local\Android\Sdk\platform-tools"

  1. run this in cmd "adb connect localhost:5555" or whatever port given by bluestack.

or just run directly from Win+R

"C:\Users\Your Username\AppData\Local\Android\Sdk\platform-tools\adb connect localhost:5555"

n.b. localhost = 127.0.0.1

Nialixus
  • 79
  • 1
  • 7
1

On BlueStack 5 it should be in Advanced -> Android Debug Bridge

Mjho
  • 11
  • 3