adb does not see visual studio emulator for android instance
Asked Answered
V

1

10

Uber goal: debug/deploy react-native android application on Windows machine

Problem: When deploying to the emulator react-native run-android fails with > com.android.builder.testing.api.DeviceException: No connected devices!. I tried running adb devices, but that returned no devices. My assumption is that to get this working I need to at least make adb aware of the emulator, and so here I am.

Versions
Windows 10 Version 1703 (OS Build 15063.540)

abd Android Debug Bridge version 1.0.39 Revision 3db08f2c6889-android

Visual Studio Emulator for Android 1.1.622.2

Android OS hosted by emulator KitKat (4.4) API Level 19

Emulated Device 5" screen XXDPI Phone "Similar to Samsung Galaxy S5, Sony"

Setup

  • Android OS:
    • Enabled developer mode
    • Turned on USB Debugging
  • VM:
    • 2 GBs memory
    • 2 virtual processors
    • 1 Windows Phone Emulator External Virtual Switch
    • 1 Windows Phone Emulator Internal Virtual Switch

Result
adb devices returns that it can't find devices followed by two blank lines:

List of devices attached
<blank line>
<blank line>

What has already been tried/verified

  • Verified emulator boots
  • Verified emulator has a network connection and IP address (I can reach internet from emulated android)
  • Verified I can ping said IP address from the host Win 10 machine
  • Verified I can find (via adb devices) and deploy (via react-native run-android) to real device attached by USB
  • Tried forcing adb connection with adb connect 192.168.0.2:5555 and adb connect 192.168.0.2:5554 and received following error:
    • unable to connect to 192.168.0.2:5555: cannot connect to 192.168.0.2:5555: No connection could be made because the target machine actively refused it. (10061)
    • Couldn't find remedy for this online

Request for Help
If anyone knows what might be going on and can provide some guidance to resolve, I'd greatly appreciate it. If you need any additional information just ask, and I'll provide it (helpful hints on how to gather it, if non-obvious, would also be appreciated).

Thanks so much for reading this far :)

Vomitory answered 17/8, 2017 at 11:45 Comment(0)
S
2

I was facing similar issue and in my case the setup was like following

Versions

  • Windows 10 pro Version 1803 (OS Build 17134.165)
  • Visual Studio Emulator for Android Android
  • OS hosted by emulator Marshmallow (6.0.0) (4.4) API Level 24 Emulated Device 5.7" screen XXDPI Phone "Similar to Samsung Galaxy note4"

In my case I also installed Android Studio which I think it has contributed to the problem by installing SDK under my user folder

C:\Users\[name with space]\AppData\Local\Android\Sdk

Visual Studio also installed Sdk in program files

C:\Program Files (x86)\Android\android-sdk

I decided to move/install android-sdk in c:\Android to avoid issue

Android SDK location should not contain whitespace, as this cause problems with NDK tools

Solution

What I had to do was to consolidate all the Environment variables and Registry entries to point to the right folder

This Stackoverflow question/answer would help in setting registry

'Visual Studio Emulator for Android' devices are not listed in the Android Device Monitor

Then from within visual studio (Tools > Android > Android SDK Manager) open SDK Manager

Open SDK Manager

Go to tools tap and make sure "Android SDK Location" is set to C:\Android\Sdk and also following items are checked

Android SDKs manager

Then in environment variable make sure There is System Environment variable called ANDROID_HOME and the value should also be c:\android\sdk

In my case there was a ANDROID_HOME User Environment which was overriding the system one. Either get rid of that or change it to c:\android\sdk

Once you've updated all these registry and environment variables close all command prompt windows and open a new one (to have environment variables set correctly)

Then check android home by running following command

C:\>echo %ANDROID_HOME%
c:\android\sdk

Also echo %path% and it should have a path pointing to c:\android\sdk\platform-tools and no other paths Then run adb --version and make sure it is running as c:\android\

adb --version

and then run

adb kill-server
adb start-server

Once you have done that lunch Visual Studio for Android and run your image of choice. Then adb devices should return the emulator IP address

Extra Resources

There is a good documentation for general troubleshooting the Visual Studio for Android which you can follow for initial troubleshooting:

https://msdn.microsoft.com/en-us/library/mt228282.aspx

Sot answered 13/7, 2018 at 0:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.