Xamarin.Android Player Using C# - Part Three

Introduction
 
Xamarin Android Player integrates with Visual Studio and Xamarin Studio so that the developers can build, deploy, and debug their apps right from their favorite IDE. Additionally, you can run the Xamarin Android Player side-by-side with the Windows Phone Hyper-V emulator without any conflicts for a great development experience on Windows.
 
The Xamarin Android Player runs Android x86 virtual machines using hardware accelerated virtualization technology and is available on both Windows and Mac OS X. It supports OpenGL.
 
To Know More  About Xamarin
Description
 
How Xamarin Android Player works and boosts its performance in Windows, I will tell you step by step.
 
Details Of Xamarin Android Player
 
Build Android (.APK) applications required for running the application, either on physical hardware or using an emulator or simulator. Using hardware, however, but not always the most practical. In some fields, it can be simpler and more cost effective to simulate/emulate the Android hardware using a tool such as the Xamarin Android Player.
 
The Xamarin Android Player was developed to provide a vet fast running simulator that will allow developers to concentrate on creating great applications and without having to worry about hardware deployment.
 
The Xamarin Android Player utilizes VT-x and AMD-V hardware accelerated virtualization and OpenGL 2.0 to provide fast boot times and a snappy, smooth user interface. It allows fine-grained control over hardware features such as the battery level or the device location.
 
Use of Xamarin Android Player Over Android Emuator
 
Android emulators are slow to boot and perform poorly. So it was struggling with slow emulators, so Xamarin Android Player for fast performance and boot is introduced at Xamarin Evolve 2014.
 
Open Graphics Library (OpenGL)
 
OpenGL is platform independent, rather than cross platform. It is just a specification for the interface of a graphics library. OPENGL REQUIRES WINDOWS FIREWALL PUBLIC NETWORK TO OPEN OR RUN ANDROID DEVICE.
 
Step To Open Xamarin Android Player
 
Go to All Program in your System / Windows 
 
 
 
You can see the opening window....
 
 
 
 
Steps To Install Xamarin Android Player On Windows
 
The Xamarin Android Player depends on virtualization and OpenGL. This means that it cannot run inside virtual machine instances nor can it work over Remote Desktop or VNC.
 
For  Windows 7, Windows 8, and Windows 8.1, the Xamarin Android Player requires VirtualBox 4.3.18 or higher, which will be installed or updated as necessary. For Windows 10, you must upgrade VirtualBox to version 5.0.2 or higher.
 
Requirements for running the Xamarin Android Player on Windows
  • Any 32 bit or 64 bit version of Windows 7, Windows 8, Windows 8.1, or Windows 10
  • 2 GB of RAM
  • 2 GB of free hard drive space
  • A graphics card that supports OpenGL 2.0
  • It is recommended that hardware-assisted virtualization be enabled in the BIOS (if available)
  • For maximum performance, disable Hyper-V
First, download the appropriate installer for your operating system, and then proceed to the appropriate section for your operating system.
  • Windows installer - 64 bit
  • Windows installer - 32 bit
When you first run the Xamarin Android Player installer on Windows, it may start by installing VirtualBox as shown below....
 
 
Virtual Box Installs Permission
 
During the installation, you may be asked to install device software as shown below....
 
 
 
About Virtual Box
 
It is developed by Oracle Corporation. Oracle VM VirtualBox is a free and open-source hypervisor for x86 computers currently being developed by Oracle Corporation. The world’s most popular cross-platform virtualization software enables you to run multiple operating systems on your Mac, PC, Linux, or Oracle Solaris machine.It is used to Test, Develop, and Demonstrate Across Multiple Platforms on one Machine.
 
 
 
Once the VirtualBox installer is finished, the installer will proceed to install the Xamarin Android Player. 
 
Once the installation is complete, run the Xamarin Android Player and the Device Manager will appear as mentioned above images....
 
First Time Run Tips
 
The first time an emulator image runs it may take longer than normal to start up while the virtual machine is initialized. Subsequent runs will start up much, much faster.If you are using Microsoft Windows, Xamarin Android Player will ask to set up a host-only network interface
for communicating with the virtual device. If you are using User Account Control, accept the prompts to allow the VirtualBox Interface, Virtual Network Configuration Tool, and Network Command Shell to make changes to the computer.
 
Virtual Android machine
 
The Xamarin Android Player communicates with the virtual Android machine over a host-only network that is classified as public by Windows. If you are using a firewall product other than Microsoft Windows Firewall, you may need to open port 22468 so that AndroidPlayer.exe may communicate with the virtual machine.
 
Once the Xamarin Android Player starts running, it behaves very much like the default Android emulator that is available with the Android SDK in my part-2 session . For example, you can unlock the device by dragging the unlock slider to the left. When you do so, the Android Player should resemble the following screenshot,
 
 
 
Buttons With Keyboard Shortcuts
 
In the details of the actual hardware buttons, a menu is available on the right hand side to simulate some of the actions that would be performed by buttons. The following table describes each of those buttons and provides keyboard shortcuts:
 
Settings
 
 
 
Volume Up
 
 
 
Volume Down
 
 
 
Rotate
 
 
Take Screenshot
 
 
 
Backspace
 
 
 
Home
 
 
 
Recent Apps
 
 
 
Menu
 
 
Google Search
 
 
 
Power
 
 
 
Other Functionality
 
   
 
 
 
Open Xamarin Android Player using Xamarin Studio
 
It is possible to start the Xamarin Android Player from Xamarin Studio. Emulator images will appear in the Device Manager drop down, as shown in the following screenshot:
 
 
 
When the application is run, Xamarin Studio will start the emulator image (if necessary), deploy the APK, and then start the application.
 
It is possible to simulate two-finger multi-touch input by holding the Alt/Option key and clicking on the screen.
 
Open Xamarin Android Player using Visual Studio
 
It is also possible to start the Xamarin Android Player from Visual Studio. Emulator images will appear in the Virtual Device Manager drop down, as shown in the following screenshot,
 
 
 
Image Keyboard Description
 
To simulate a pinch-zoom press and hold the Alt/Option button and drag towards the centre of the screen (for zoom out) or away from the centre of the screen (for zoom in). To simulate a two finger drag hold the Alt/Option + Shift while clicking and dragging on the screen.
 
Settings Pane
 
 
 
The Xamarin Android Player settings pane provides some extra information about the version of Android that is installed. It also provides the user interface for setting the device location, and for controlling the battery settings. The screenshot above shows the Xamarin Android Player with the settings pane open.
 
Battery
 
The Battery Settings pane, pictured below, allows control over how the emulator simulates its power.
 
 
 
Steps to open the battery settings pane
 
Press Ctrl-Option-B
Click on the Settings Button and then select the Battery label.This pane makes it possible to simulate if the emulator is connected to power (charging) or running off thebattery (discharging). If running off the battery it is possible to set the battery level to a value between 0% to 100%.
 
Location Settings / GPS
 
It is possible to set the location of the simulated device by using the location control window, shown in the screenshot below:
 
 
 
Steps to open the location control window
 
Press Ctrl-Option-L 
Click on the Settings Button and then selected the GPS label.The edit boxes and sliders allow control over the various parts of the location,
  • Latitude - A geographical coordinate in the range of -90˚ to 90˚.
  • Longitude - A geographical coordinate in the range of -180˚ to 180˚.
  • Altitude - The height of the device in meters between the range of -10 000m to 10 000m.
  • Bearing - Choose a bearing between 0˚ and 360˚. It is possible to rotate the compass and set the bearing.
  • Accuracy - Enter the desired accuracy of the virtual device’s location in the range of 0m to 200m.
Google Play Services
 
The Android devices ship with apps like the Google Play Store, Gmail, Google Maps, and so forth installed. As well, Google Play Services providesmay important API's such as Maps or Google CloudMessaging that developers may wish use in their applications. These applications and APIs are proprietary and require a special license from Google before they may be distributed. The Google Apps and Google Play Services have been packaged by independent developers in the Android community into a flashable zip format. It is possible to install Google Apps and Google PlayServices on the Xamarin Android Player yourself by following these steps,
  • Download the package from the internet. There are many sources for this, one possible source is the CyanogenMod web site.
  • Start up the Android Player and unlock it.
  • Drag and drop the zip file that you downloaded onto the Android Player.
  • Restart the Android Player.
Error Messages and Steps To Fix It
 
Error message 1
Error when attempting to find Virtualbox; please check it's installed and try again. Xamarin Android Player will now exit In some cases, VirtualBox does not add its path to the Windows %PATH% environment variable during installation. To work around this issue, try restarting Windows.
 
If you still see this error, add the VirtualBox path to the %PATH% environment variable. Open Control Panel > System > Advanced System Settings > Environment Variables > System Variables and add the following to the Path system variable,
 
C:\Program Files\Oracle\VirtualBox
 
If you installed VirtualPath in a different location, use that path instead. Remember to delimit this addition to the Path system variable with a semicolon.
 
Like , E:\Satyaprakash\Oracle\VirtualBox;
 
Error message 2
OpenGL server is unreachable. Please check that Xamarin Android.
 
Xamarin Android Player is allowed through your firewall on public networks . 
 
Steps to fix the OpenGL related issue
 
Xamarin Android Player uses a Host-Only Network to provide OpenGL display of the virtual machine, so this error can occur if your network adapter is misconfigured, removed, or blocked by your firewall. Xamarin Android Player attempts to reconfigure the network adapter if it is misconfigured, but an external firewall can interfere with this process. Please alter your firewall settings to allow communications over port 22468 on private and public networks and restart your PC. This error may also occur if you are using a graphics card that does not support OpenGL, or if you are running Xamarin Android Player inside Virtual Machine or Remote Desktop software without OpenGL support.
 
Error message 3
Cannot connect to the device via ADB
 
Once fully booted, the Xamarin Android Player virtual device should automatically connect to ADB. If ADB fails to connect, please try closing Xamarin Android Player, then open Task Manager (CTRL-Shift-Esc) and force kill adb.exe, then restart Xamarin Android Player.
 
Error message 4
The virtual device runs slowly
 
The Xamarin Android Player emulated device will run significantly faster if your CPU supports hardwareassisted virtualization, and this is enabled in the BIOS. If your CPU supports this, please ensure it is enabled by booting your PC into the system BIOS, and checking for an option named "Hardware virtualization”, "VT-x”, "AMD-V” or similar.
 
Right, you need to close Xamarin Android Simulator
  • Click the Power button on the right-hand side (Esc) .
  • Then, Close the cross button (X) on top right side.
Module Summary

We learned the following in this article.
  • What Is Xamarin Android Player.
  • Steps for Installation in windows.
  • Different parts , features and functionality of Xamarin Android player.
  • Fix system configuration related errors while working with Xamarin android player. 


Similar Articles