Emulator For Android In Visual Studio 2015

Introduction

Microsoft has launched its new version of Visual Studio for developers, Visual Studio 2015. Microsoft introduced many new features in it compare with the older versions of Visual Studio like Visual Studio 2013, Visual Studio 2010 and older versions. Now Microsoft Visual Studio 2015 is more powerful, more reliable and easier to use with  more templates to develop web applications, mobile applications, cloud-based applications, Android applications, iOS applications and many more. Now portions of .NET is open-source for every one. So now we are free to work with the open source portions of .NET. There are several components, such as ASP.NET and the C# compiler that were already open source, but now, Microsoft has introduced several new core components to it. As open source .Net applications can target the Linux operating system and Mac operating system. It provides new opportunities, new functionality and environment and feels good and is better for the .NET programmers and developers.

Note

Visual Studio 2015 will not be installed on a computer that has any previous version of Visual Studio installed. Therefore to install Visual Studio 2015 in your computer, first you must uninstall the old CTP related to the previous version of Visual Studio.

Visual Studio 2015 introduced many new features for the developers. These features are described below:


We can create cross-platform mobile development using Visual Studio. There are four things by which we create mobile applications. There are four basic requirement for making cross-platform mobile applications in Visual Studio. They are as follows:

Now I will discuss the Emulator for Android with Visual Studio.

Visual Studio Emulator for Android

People can download an Emulator for Android that works with Visual Studio 2015 free of cost. The new emulator introduced by the Microsoft that is very user-friendly to use, easy to configure, very reliable and also easy to install. It also provides features for the developers to easily do the cross-language support of features. Visual Studio already has a good emulator for Windows Phone, but Visual Studio 2015 enables developers to make more devices or cross-platform application like iOS and Android.

How to use Visual Studio with Android


The following describes the step-by-step process for developing an Android application in Visual Studio.

We need some tools to develop an Android application in Visual Studio.

  • Java Development Kit (JDK)
  • Android SDK
  • Xamarin Studio

Procedure

Step 1
  
First open Visual Studio 2015 then create a new project. Then in the template field, select the C# template. Explore the C# template. You have seen an Android template, select it.



Step 2

When you select the Android template you have a template with the name Build Native Android in C#. it is a single template.

Step 3

When you click on the OK button you will get a screen to download Xamarin. Click on the download button.




Step 4

After clicking the download Xamarin button, your Xamarin is downloaded. But pay attention when downloading and the installation of the Xamarin is in a running process. All the tools of Visual Studio should be closed.

There are many things that happen during the downloading and installation of the Xamarin that are shown in pictures. So wait for it because Xamarin takes time during the installation process.



Step 5

After the successful Installation of Xamarin, restart your system.

Step 6

Now again open the Visual Studio 2015 preview. Create a new project then go to the template field. Select C#, explore it and select Android. Now you have seen the ohter templates in it. Choose the first template for blank App (Android) and click on the OK button.



Step 7

After selecting the Blank app (Android) in you Solution Explorer an Android app is created that has some files.



Step 8

Now go to the Solution Explorer, select app, select property and change the property like the picture.



Step 9

Go to the Visual Studio tool, select Android and start the Android SDK Manager.






Step 10

Again go to Visual Studio tools, select Android and now run the Android Virtual Device Manager.



Step 11

Create a new Android Virtual Device Manager as in the picture.



Step 12

Start this Android Emulator. Launch it. Wait for some time because the first time it takes some time to start the emulator. So be patient.

Step 13

Your Android Emulator look like this.



Step 14

Now you can design or make an Android application as you want with the C# code. Go to the Solution Explorer, explore the resoures and explore the layout. You will see a file named Main.axml. Click on it. You can now make a design or create a layout as you want for you application.



Step 15

Now in the toolbar you found some new tools that are related to the Android application like this so you can use these tools. So you can make your app and run it using the emulator. When you run your application then check in the output window, it generates some files that are necessary to run the application so it can take some time.



Code:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent">  
  6.     <Button  
  7.         android:id="@+id/MyButton"  
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="wrap_content"  
  10.         android:text="@string/Hello" />  
  11.     <Button  
  12.         android:text="Click here Rizwan "  
  13.         android:layout_width="match_parent"  
  14.         android:layout_height="wrap_content"  
  15.         android:id="@+id/button1" />  
  16. </LinearLayout>  
  1. using System;  
  2. using Android.App;  
  3. using Android.Content;  
  4. using Android.Runtime;  
  5. using Android.Views;  
  6. using Android.Widget;  
  7. using Android.OS;  
  8.   
  9. namespace android_app  
  10. {  
  11.     [Activity(Label = "android_app", MainLauncher = true, Icon = "@drawable/icon")]  
  12.     public class MainActivity : Activity  
  13.     {  
  14.         int count = 1;  
  15.   
  16.         protected override void OnCreate(Bundle bundle)  
  17.         {  
  18.             base.OnCreate(bundle);  
  19.   
  20.             // Set our view from the "main" layout resource  
  21.             SetContentView(Resource.Layout.Main);  
  22.   
  23.             // Get our button from the layout resource,  
  24.             // and attach an event to it  
  25.             Button button = FindViewById<Button>(Resource.Id.MyButton);  
  26.   
  27.             button.Click += delegate { button.Text = string.Format("{0} clicks here rizwan!", count++); };  
  28.         }  
  29.     }  
  30. }  

Output:




Summary

This is the overall view of how to make an emulator in Visual Studio 2015, how to run it and what problems you will encounter when creating an emulator for Visual Studio 2015. I hope now you can easily make an emulator in Visual Studio 2015 and run your application easily on it.


Similar Articles