Xamarin Android Simulator launching forever - visual-studio

I am using Visual Studio 2017 (version 15.4.5) & its default emulator for Android device.
I just try to run simple hello world of Xamarin Form. When I click to Debug
It's has just launch the Android Device, and stucking at it's forever, no deploy and Visual Studio's progress bar is always running... I have waiting more than 16 hours.

After all, I found a solution,
Open Regedit, under HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node node,
Create a new key named 'Android SDK Tools', create a variable name Path, the value point to 'C:\Program Files (x86)\Android\android-sdk'

enable Hyper-V
install Intel HAXM Drivers
use x86 system images
enable Host GPU
Use Fast Deployment (debug mode only)
https://university.xamarin.com/resources/working-with-android-emulators
https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/android-emulator/google-emulator-manager?tabs=vswin
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/debugging/visual-studio-android-emulator

Related

How to run UWP app on Simulator and simulate a location?

I need to test my UWP application using a simulated location.
I assume that I can do this by running the app on the simulator instead of the local machine, but there is a problem. When I select Simulator, the simulator opens but never finished initializing. It is stuck in a state with a series of dots running across the screen.
In the Visual Studio window, the last message I see is "Registering the application to run from layout". I don't know what that means.
I found some old posts that suggest I need to acquire or renew a license. I checked to make sure that Developer Mode was enabled on my machine and I also ran "Get-WindowsDeveloperLicense" from an elevated PowerShell account, but it did not fix the problem.
Thanks,
Frank
How do I start a UWP simulator?
Your system need to support Hardware-assisted virtualization and
Enable Hyper-v for emulator
Then switch the Solution Platforms to X86 or x64.
For more info please refer Run Windows Store apps in the simulator
simulate a location?
The Visual Studio 2015 simulator does not include the geolocation button. This is because the Windows 10 simulator does not include geolocation simulation. If you need to do this kind of simulation, you can use the Visual Studio 2013 simulator on Windows 8.1 or earlier operating systems.

Microsoft visual studio doesn't show any android emulator or physical device for Xamarin project

I have a xamarin project and i want to debug it, but visual studio doesn't show any emulator or physical device.
this is the menu
I wanted to restart adb from tools > android but it's disabled. but when I open a non xamarin project (for example a web porject) this options is enabled.
I can see my device in cmd with command adb devices and in android studio, every thing is fine and I can deploy some java application to my phone.
do you have Any idea?
Update
I created new project and in this new project, every thing is fine and I can debug with my phone or emulators.
but in my existing project which I'm currently working on, there is no device in list.
It happened to me just now using vs 2019, to fix this, manually remove obj and bin folders restart vs, and that's all :)

react-native and Visual Studio Emulator for Android

is it possible to run react native app on Visual Studio Emulator for Android (standalone) and if yes what are the steps to set it up? I can successfully start emulator, that part works but cant figure out how to config react-native to use it instead of "adb devices".
My current attempts end with error:
Could not debug. Error while executing command 'adb devices': Command failed: adb devices
'adb' is not recognized as an internal or external command,
operable program or batch file.
I know about Android Studio and virtual devices that come with it but I would like to try that as the last option. My environment is: Windows 10 pro, VS Code (with React Native Tools Extension), react-native, yarn.
UPDATE
even though I did not get anywhere in my attempts to make it work
I just would like to share what knowledge I gained while struggling with this issue
because it is possible that my issues are specific to my environment but it might work on another PC.
Theoretically it requires very few steps to run react-native in Visual Studio Emulator for Android
in VS code without installing Android Studio or Visual Studio.
Install Visual Studio Emulator for Android, standalone
https://www.visualstudio.com/vs/msft-android-emulator/
download Android Debug Bridge (adb)
it is included with Android SDK Platform-Tools, download and read more here:
https://developer.android.com/studio/command-line/adb.html
it downloads as zip file, you unzip it and then add a path to adb.exe in PATH environment variable,
so you can execute adb command from any path. I am using yarn and it needs that to know where adb.exe is.
It is kind of a connector between your app and virtual or real android device
it has to be running before you start emulator and basic command are:
to stop - adb kill-server
to start - adb start-server
to see list of devices that adb recognized - adb devices
I also found a specific instruction on how to make Visual Studio Emulator for Android work with adb:
https://msdn.microsoft.com/en-us/library/mt228282.aspx
'Visual Studio Emulator for Android' devices are not listed in the Android Device Monitor
it is a registry edit for key
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools
apparently Visual Studio Emulator for Android is using that and you can create it if it is not there
and just add/modify Path variable to be a path to adb.exe.
now you can start Visual Studio Emulator for Android and after that open integrated terminal in you react native VS code project
and type:
yarn run android
and if I get it right (and in the perfect world) your app should get installed and shown in Visual Studio Emulator for Android,
well, not for me, my emulator never shows up as a device when I type adb devices, all I see is a blank two lines.
So I think I spent enough time on this trying to make it work and in my case the answer to my own questions is:
theoretically you should be able to run Visual Studio Emulator for Android with react-native from VS code but in reality
it probably will not work, so seek something more reliable.
I did see a little light at the end of the tunnel when I tried connecting my phone with USB using expo app, adb picked it up right away,
"yarn run android" started doing something and expo even tried to load my app, I held my breath, my heart was racing, I was ready for a miracle... and .... boom... it just crashed, but this could be easier
for me to resolve though, it appears some networking config issues, my phone does not recognize IP address which was in the output after running yarn
and if this works,(big IF) then it is still good, I can run/debug react-native without using Android/Visual Studio.
Final update:
could not make it work, stopped all attempts and went for Android Studio instead, Android Studio emulators work with react native and expo without any issues. (well, not yet, sample app runs OK at least.)
The same symptoms occurred to me when trying to set both React-Native and VS Emulator for Android together, and the following steps solved them:
On the VS Emulator for Android, I checked my emulated phone's IP at the Tools/Network tab. Emulator Adapter #1 refers to the emulated phone.
Then, I headed to the terminal and ran adb connect <ip_address>:5555. That made the emulated phone available to Android Studio as well as to React-Native.
if you already install android studio
then add C:\Users\manu\AppData\Local\Android\Sdk\platform-tools path into environment path (replace your username instead of manu)
if you have not android studio then
need download adb from https://github.com/intel/haxm/releases/download/v7.0.0/haxm-windows_v7_0_0.zip
then install
intelhaxm-android.exe
.
open a new terminal and now adb commnad will work
it is haxm source website https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm

Windows 10 - How do I test touch events without a touchscreen?

I need to test my Windows app using touch events but don't have a touch screen available.
Microsoft.Windows.Simulator.exe
Located in C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Simulator\16.0\Microsoft.Windows.Simulator.exe
The Simulator has modes that allow for basic touch events using the mouse, as well as pinch-to-zoom, and 2 finger rotation. It simulates your current Windows machine so you can even open up your code in VS, run your app, and set breakpoints that would normally only hit when using touch events.
Edit: based on the comment of Luishg, you need to install both Visual Studio and the Visual Studio UWP package for the Simulator to be installed.
Microsoft.Windows.Simulator.exe is no longer part of Visual Studio 2022.
If you need simulator then install Visual Studio 2019 and UWP feature.
You can actually launch this from visual studio now:
https://learn.microsoft.com/en-us/visualstudio/debugger/run-windows-store-apps-in-the-simulator?view=vs-2019
Set the simulator as the target
To run your UWP app in the simulator, select Simulator from the drop-down list next to the Start Debugging button on the debugger Standard toolbar. This option is only available if your app's Target Platform Min. Version is less than or equal to the operating system on your development machine.
PS. mine didnt actually work first time I had to reboot my pc to get it working

Why does visual studio 2013 run adb.exe when I try to debug using an android device?

I have a Sony Xperia Z3 and I'm trying to debug an Apache Cordova application aka: Multi-device hybrid application on my device but visual studio builds and then opens adb.exe after the build is complete. It doesn't launch the application on my device although my device does prompt for verification.
I have developer options enabled on my device and I have USB debugging enabled.
I followed the steps on MSDN to debug an application on my device but it still doesn't work: http://msdn.microsoft.com/en-us/library/dn757059.aspx
I created a self signed keystore using the keytool in jdk and that works fine.
I have all of the necessary drivers installed and my device appears under the "adb devices" list of connected devices.
I tried deleting all the drivers and reinstalling them as well as updating them.
The ripple emulators work perfectly. It's just when I try to debug on a device.
well, that's a known issue with Cordova visual studio 2013 update. please see below blog for the known issue list for Cordova and search for adb on page. you'll get to know about this and there is no fix available for till now. please update me too if you find any :)
I'm pretty sure that you CANNOT debug a cordova visual studio project in an android DEVICE! The ripple emulators also are very limited, some plug-ins just simply DON'T work in the emulator!

Resources