Use Visual Studio 2012 + xamarin to build a C # andriod Development Environment

Source: Internet
Author: User
Tags oracle vm virtualbox vm virtualbox visual studio 2010

Step 1: Install Visual Studio:

Visual Studio 2012 (or Visual Studio 2010) is because the xamarin for Visual Studio plug-ins only support versions 2010 and 2012 so far. The installation process is not described here.

Step 2: Install xamarin:

1. Go to http://xamarin.com/downloadhere to register a account number, you can download the installation package of xamarin. For example:

This installation package can be tried for 30 days after being downloaded and installed, and will be renewed after the expiration of 30 days. You can find it online.

2. during xamarin installation, the program will install Java, xamarin, xamarin studio, andriod SDK, andriod ndk by default, java has been installed on my computer and the JDK path has been configured. If you don't know how to configure Java on the Internet, you can find a lot of configuration methods on the Internet. After this process is completed, you can open your Visual Studio. In the tool menu, an additional xamarin account option is displayed, for example:

Click the option in the red box above to display a logon interface:

Select xamarin. andriod and log in:

Enter the email address and password you registered when you first downloaded xamarin, and click log in. The following will appear:

Note that the above process should be used in the connected network status. If you have already connected to the network but the logon interface still prompts you to connect Internet processing... if your Visual Studio installation problem occurs, I will see this situation. Because it has been solved, no, so you can understand it. If the connection is successful, the following will appear:

By now, most of the work has been done, and the rest is to install the andriod simulator. In fact, at this step, you can create an andriod project by yourself to see the effect.

In fact, after xamarin is installed, there are two more options: andriod and iOS in the template of the newly created project. After the app4 project is created, you can click the green start button to see the following, it also prompts you that a deployment error occurs. Do not panic when you see this. This is a normal phenomenon.

If you are prompted to generate an error, the error message is:

Error 1 cannot find 'aapt.exe '. please install the android SDK build-tools package with the 'C: \ Users \ Administrator \ appdata \ Local \ Android-SDK \ tools \ android. bat 'program. unittestapp1

Open "tool-> Option-> xamarin" in your Visual Studio, and click xamarin. The following figure appears, check whether your Visual Studio can find the andriod SDK path and the andriod ndk path on your computer. Generally, if you install xamarin after installing Visual Studio 2012 (or version 10), Visual Studio will automatically identify your installation path without changing the installation sequence, I have never tried it. Other people on the Internet say they want this path!

If your SDK and ndk are correctly configured, but the above error is still prompted, I suggest you find the SDK manager.exe under the SDK path directory and run this file, it takes a long time to check and update all the options in the box, so I hope you will be patient! The Update log dialog box appears during the update process. The update log dialog box prompts you that the update is complete. Otherwise, the newly created program cannot run if the log is interrupted.

 

If the above steps are completed, it is not far from the success. The last step is to install the andriod simulator. This is the result of the final test of your program, so it is very important.

Step 3: Install the andriod simulator. You have two solutions in this step. One is to configure the android simulator that comes with xamarin. I checked the relevant information and found that the simulator that comes with xamarin is very slow, the operation was not smooth, so I chose the second solution and genymotion. This guy claimed to be the king of the android simulator. After installation, I found that it was okay and met my requirements, I have not studied the first solution. If you are interested, you can try the first solution.

1. Download genymotion

Https://cloud.genymotion.com/page/customer/login? Next =/, register and download, and then install. During the installation process, genymotion and Oracle VM virtualbox will be installed at the same time. After installing the Oracle VM virtualbox, a prompt is displayed, "is the Oracle VM virtualbox installed? Do you want to start the program ?", The check box of his multiple choice box is marked by default. Remove the check box first. A dialog box is displayed, prompting you that "genymotion has been installed. Do you want to run it ?" This check box is also checked by default. Do not remove this check box. Click OK to start genymotion. If the preceding check box is not removed, genymotion cannot run and is stuck on the running start interface.

When you run genymotion for the first time, you will be prompted to enter the user name and password. You can remember the password and you will not lose it. Then, you are prompted to add a VM:

Click Yes and select the virtual machine model you want to add:

Click Next to download the VM image:

Note that the host image you download must be in a status that Visual Studio can recognize. For details, you can check whether the API version of the image you download can be compatible with Visual Studio. The API version of the image you downloaded is specified when you select the image, the lowest API version that your Visual Studio can be compatible with requires you to set it under Solution Explorer of the new project, such:

Right-click Properties and set minimum andriod to target. You can set a lower API version.

After the above settings, return to genymotion, select the new virtual machine, and click play to run the virtual machine.

After running it, it is like this:

Now let's take a look at the target andriod device column of Visual Studio and you will have the name of the currently running andriod analog device,

Click the Green run button of Visual Studio to run app4. Wait a moment and check the andriod simulation device that you just opened. Then, you can find that the mobile phone interface is actually running the program I created, so far, the entire configuration process has completely ended.

The following figure shows the result after you click "run:

The figure below shows the result after I click the simulation interface twice:

 

Note: during the installation process, I also encountered the problem that the android simulator cannot be started, as shown below:

The cause of this error is that your original virtual network card is disabled, and the new virtual network card does not match your actual network. At this time, you can have two solutions: first, enable the disabled Nic, then enable the Oracle VM virtualbox software, and set the NIC to enable for you in the settings. The second method is to set the IP address of your virtual network card to automatically obtain it.

The above sharing experience is based on my personal configuration process over the past few days. It may be helpful for some people who want to configure this environment, but it will also be one-sided, you should take the reference as a good reference, and practice the specific situation. If you have any errors, please include them!

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.