Visual Studio & Xamarin: deploy to Hyper-V emulator failed - android

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?

Related

How to debug Visual Studio 2019 not connecting to Android x86 AVD

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?

Visual Studio emulator for Android not starting in VMWare Fusion on macOS Sierra

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.

Visual studio cordova app build is failing

Google Sdk adb fastboot usb driver installed.. there is no issues and even not alerting any error message but app build is failing..
There is no use even after installing CTP 3.1 for VS 2013.
Kindly help me on it
As Alan says, VS will try to launch the app on the device if you have selected the "device" option and are trying to run or debug the app on the device. Does building to Ripple work? If its failing only for device, Can you please attach the complete build log?
VS uses ADB to connect to the device and so even though you have installed the driver, the ADB might not be able to see the device.
Can you run the following command to see if ADB lists the connected device:
C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe devices
Also please check whether your device shows up in the windows device manager.
Let me know what you find.

adb needs an upgraded sdk to work but cordova needs a downgraded sdk. How can I make both happy?

When I type adb devices -l this is the output:
$ adb devices -l
List of devices attached
VS9854G22b261d6 offline
I think that VS9854G22b261d6 is my phone. I had to install LG drivers before that would show up.
It seems like the solution to that "offline" problem is to update the android sdk. But, cordova requires an older SDK (api version 19, right?) So how can I make both adb and cordova happy?
I'm on Windows 8.1 and I have a Verizon LG G3 device. I have enabled USB debugging on the device. When I type cordova run android it starts the emulator and deploys to that. I am expecting this to deploy onto my connected device instead of onto an emulator. The "hello world" app deploys fine to the emulator, but I'm trying to deploy it to my device and I can't figure out why it's not even trying to do that.
When I type cordova run android this is the output:
...
BUILD SUCCESSFUL
Total time: 2 seconds
Built the following apk(s):
C:\...\cordova\platforms\android\ant-build\CordovaApp-debug.apk
WARNING : No started emulators found, starting an emulator.
Waiting for emulator...
### Error: could not find emulator icon resource: android_icon_32.png
In my case, I plugged into a different USB port and then it said "unauthorized". I changed the USB connection to camera and then the device asked me to authorize it. Then adb devices said "device" and cordova run android worked as expected. Seems to be a ton of different solutions to the same problem. This is all I needed.

adb doesn't see device online, android studio does

I have the opposite of this problem: Android Studio doesn't see device
Android studio sees the device and can deploy to/ run on device no problem.
But I'm trying to use apache cordova and cannot see the device online from the command line.
adb devices
shows my device number, and "offline".
I've tried all of the recommended steps here https://stackoverflow.com/a/9966660/210757
Any suggestions?

Categories

Resources