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
Resultadb 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
adb devices
) and deploy (via react-native run-android
) to real device attached by USBadb 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)
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 :)
I was facing similar issue and in my case the setup was like following
Versions
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
Go to tools tap and make sure "Android SDK Location" is set to C:\Android\Sdk
and also following items are checked
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\
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With