I'm trying to debug a NativeActivity C++ Android application from Visual Studio 2019, using the Visual Studio Android tools.
My system uses Windows 10 Pro, with Hyper-V enabled, running a number of other Hyper-V images (this cannot be turned off for reasons,) but the development Windows install is the "main" (host) OS.
I can build the sample application, and I can attempt to connect it to the VisualStudio_android-25_arm_phone AVD. However, one of two things happen:
If I just run out of Visual Studio, I get the error:
Severity Code Description Project File Line Suppression State
Error Error installing the package. The device 'VisualStudio_android-25_x86_phone' is invalid or not running. Please switch to another device, or use the Android Virtual Device (AVD) Manager to start a compatible emulator, or connect a compatible Android device. XMCRemote3.Packaging 0
If I start the appropriate x86 AVD inside the AVD manager, the device actually starts up. If I then try to run in Visual Studio, I get an error dialog from the AVD Manager that the device and the host have different versions of ADB.
Device error: adb server version (39) doesn't match this client (41); killing...
* daemon started successfully
adb.exe: device offline
This is the Visual Studio log when that happens:
1>Failed to start emulator.
1>emulator: Requested console port 5556: Inferring adb port 5557.
1>emulator: ERROR: x86 emulation currently requires hardware acceleration!
1>Please ensure Intel HAXM is properly installed and usable.
1>CPU acceleration status: Android Emulator requires an Intel processor with VT-x and NX support. Your CPU: 'AuthenticAMD'
1>Error installing the package. The device 'VisualStudio_android-25_x86_phone' is invalid or not running. Please switch to another device, or use the Android Virtual Device (AVD) Manager to start a compatible emulator, or connect a compatible Android device.
1>The device is invalid or is not running.
I don't think I have the "x86 device doesn't work on AMD" problem, as I'm using Hyper-V, and the device starts up and is interactive when I launch it manually.
Sometimes, I think I might have a "ADB port number" issue, because the error message in the log sometimes talks about ports 5556 and 5557, and sometimes about 5553 and 5554. However, I wouldn't know at all where that's coming from, or what to do with it.
And, like in case 2 above, sometimes it just claims ADB is mis-matched.
What can I do about this? Do I need to update the device image, or the local tools? Both were very recently downloaded/installed.
I'm targeting SDK version 21 for both minimum and target versions.
The SDK Tools version is 30.0.4, and the emulator is 30.1.5.
The Platforms installed are 8.0/26 and 7.1/25 (the list only goes up to 8.1/27)
Interestingly, there's no "NDK" version listed in the SDKs and Tools android settings app, even though Visual Studio compiles and links it just fine.
I wonder if the Visual Studio package is installing something on the side? If so, is there another tool to manage what this is than the "Android" sub-menu in the Visual Studio "Tools" menu?
Related
I have been using android studio for the past 5 months and everything was fine. Suddenly, yesterday when i tried to debug my app android studio gave me the error of 'adb.exe start-server' failed -- run manually if necessary.
In an attempt to solve this, I
Killed adb.exe via task manager, restarted android studio and got the error
Opened command window,navigated to platform tools, adb kill-server and adb start-server, restarted android studio and still got error
Then,
I downloaded the latest platform-tools of version 28 something from the documentation.
Updated SDK tools from SDK managet to version 28.0.3
Updated Android emulator to a version of 28
Tried to debug my app, got no 'adb.exe start-server failed' error but my device is not being detected by the android adb despite it is detected by my laptop
Then i started again the command window, restarted the adb server, then i checked the connected devices on the adb by typing 'adb devices' but no devices was shown in the list.( maybe the problem is something here)
I toggled among the usb options on my phone, still my device is not detected on android.
Can somebody help me on this please?
Note: My android device is on debugging mode and this is the same device i have been using since 5 months on android studio.
Install and configure your Android device:
Install the USB driver for your Android device.
Enable USB debugging on your Android device.
If necessary, install the Android development tools (JDK/SDK/NDK).
These libraries are installed by default by the RAD Studio installer.
Add your Android SDK to the RAD Studio SDK Manager.
Connect your Android device to your development system using the USB
cable provided with your device.
At the AutoPlay prompt, select Open device to view files.
In the Control Panel, search for and select "update device drivers".
In the system Device Manager:
Your Android device should be listed under Portable Devices. Locate
and right-click your Android device, and select Update Software
Driver.
Browse to the \extras folder in your installed directory, and
select the folder that matches your Android device. Then click OK.
For example, select google for the Nexus 7 or Nexus 10 tablet.
If you do not find a folder for your Android device, see Installing the USB Driver for Your Android Device.
Verify that your Android device is now:
Listed in Windows Explorer, below the system disk drives, along with your mapped network drives.
Displayed in the Target node in the Project Manager.
I've installed VS2017 15.7 on a VMware Fusion (latest version) running Windows 10 (latest version, latest updates) with virtual Hyper-V enabled.
I created a brand new project using the Xamarin Forms template.
I tried to run it on any of the Visual Studio Android emulators and none seem to work.
The emulator starts up and seems functional.
However, Visual Studio just hangs and never seems to actually install the app onto the emulator. After a while if I click on the emulator to view the apps, I get a black screen in the emulator.
I can stop the build / deployment and Visual Studio is responsive.
Here is a similar post as to what is happening to me…
https://forums.xamarin.com/discussion/83756/visual-studio-android-emulator-black-screen-in-apps-periodically
The resolution in that post was to remove a line in the xdesku.xml file
https://creativewebspecialist.co.uk/2015/07/22/how-to-use-visual-studio-android-emulator-on-vmware-fusion/
(In Windows, you’ll need to edit the c:\program files (x86)\Microsoft XDE\10.0.10240.0\skus\android\xdesku.xml file and remove the following line from the file: GuestDisplayProvider=”VsEmulator.OpenGLGuestDisplay”)
I tried this, but still no luck.
I bumped the VM up to 10 gig and 4 processors, still no luck.
I have unchecked fast deployment in the visual studio IDE for Android properties. Also, in hyper-v I have selected processor compatibility and migrate to physical computer as well as 2 virtual processors for the emulators. These are usually the things that impact Android emulators from working correctly on the metal.
I am stumped. I am running the Visual Studio Emulator for Android. I even disabled 3D graphics as well as high res retina in the VM . I am getting runtime checks failed in deploying to the emulator.
The same test works fine on my Windows 10 desktop.
Looks like this is the supported solution from Microsoft:
https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/connect-android-emulator-mac-windows
It actually uses the emulator running on the Mac side accessed from the VM on the windows side, which is the environment I need. I can set break points and debug when needed from Windows and have the same dev environment for iOS, Android and Windows. Also, Android apps will deploy to a connected device as well if I need that, as well as this link to get it to work on Xamarin Android Player https://montemagno.com/debug-with-the-xamarin-android-player-from-visual/ . So, it looks like I am all set on this for now.
Recap:
Start the emulator on the Mac. (I use Mac VS to start this)
On the mac , from VS for the Mac, open the command Tools | SDK Command Prompt
Run these commands
adb kill-server
lsof -iTCP -sTCP:LISTEN -P | grep 'emulator\|qemu'
(this will get the ip address of the mac)
cd /tmp
mkfifo backpipe
nc -kl 5555 0 backpipe
(as long as this window is open , you can connect to it on the VM side)
Then on the VM Machine, from Visual Studio open Tools | Android | ABD Command Prompt
adb connect ip-address-of-the-mac:5555
You will then see an Unknown vm emulator in the drop down in VS to deploy the app to. It will appear on the mac side.
I'm attempting a very novice Xamarin Forms app and it builds in an instant, but then seems to hang when deploying to the emulator, i.e. I aborted after well over 20 minutes. In the output window, under Xamarin Diagnostics, I get the following last few entries:
[I:]: Found Android SDK. API levels: 22, 26
[I:]: Tracking android devices started
[D:]: TrackDeviceTask got: emulator-5554 device
[I:]: Got new device list from adb with 1 devices
[D:RunShellCommand]: emulator-5554 getprop
[D:]: Tracking avd started
[D:]: avd watcher *.ini path: 'C:\Users\brady\.android\avd'
[D:RunShellCommand]: emulator-5554 getprop
[D:]: avd watcher: got device list from avd with 1 devices
This is my debugging target:
My Xamarin Forms projects were working about a month ago, but since then I experimented with nearly every other Android enabled IDE and maybe that somehow affected my AVD.
What can I look at or change to correct this problem?
I have since learnt I must use the Emulator Manager to create an emulator. Now when I try and open the Emulator Manager, it says I must use the SDK Manager to downgrade the SDK tools to v25.x. When I open the SDK Manager, it says it must be updated, and presents an Update button. Pressing the button directs me to a download page with no download button:
The Get Started button takes me to the docs page for the SDK Manager. Now how am I supposed to update this problem child SDK Manager?
If your project compiles but won't deploy, then Visual Studio is probably not connected to your emulator.
I would recommend using Visual Studio Emulator for Android as it is much faster and has worked on every device I have used it on.
On some computers Visual Studio does not connect to the emulator when it starts. A workaround is to find the devices IP address and connect to it manually:
First open Visual Studio Emulator for Android and start one of the emulators
Next in the emulator select tools, a popup window will open, select the 'Network' tab and under the list of network adaptors note down the preferred IP address. Here my one is 169.254.160.177.
Then in Visual Studio open 'Android Adb Command Prommpt' and enter adb connect 169.254.160.177
Now that Visual Studio is connected to the emulator the application will be deployed to the device. You will need to connect to the emulator every time you restart it (don't close it while your programming).
Note: On some computers, Visual Studio will connect to the emulator automatically.
I re-installed VS2017, but the latest, v15.5.1, then recreated the project, and now everything is working fine. VS even starts the emulator automatically.
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 :)
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
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
When I'm trying to run my project Xamarin.Android in Hyper-V with Visual Studio 2015 RC (generally speaking, this error/bug or whatever may occur in different VS versions), I'm getting no deploy process to the emulator. However, the emulator has starting successfully, but nothing deployed into it. After closing the emulator, I'm getting this message:
Build Failed: MonoDroid does not support running the previous
version. Please ensure your solution builds before running or
debugging it.
My solution is:
Connect to android device in Hyper-V
Run in terminal "su root"
Run "netcfg" to obtain device ip addrress
Then in ADB command prompt type "adb connect 192.168.1.63"
After this VS/Xamarin begins the deploying process and all working fine.
End :)
Is this a bug OR can Xamarin/Visual Studio deploy applications (for example, android) to the device emulator automatically?