Developing Android Apps with C # in vs2012. Xamarin Environment Building

Source: Internet
Author: User
Tags gtk

Xamarin is a company created by Mono's founder Miguel de Icaza, designed to enable developers to write iOS, Android, Mac applications, or cross-platform mobile development in C #.

Brief introduction

Xamarin is a mono-based platform that currently has the following products (see: http://xamarin.com/products):

  • Xamarin Studio:ide, was renamed from the original MonoDevelop. Now downloaded from the MonoDevelop official website is also the Xamarin studio:http://monodevelop.com/. (Say MonoDevelop is also a branch of sharpdevelop development)
  • Xamarin.ios: Formerly known as Monotouch, used to develop IOS apps and can be published on the App Store.
  • Xamarin.mac: For developing MAC OS X applications, similar to Windows desktop apps.
  • Xamarin.android: Formerly known as Monodroid/mono for Android, used to develop Android apps.
  • Xamarin for Visual studio:visual Studio plug-ins, including iOS and Android, but currently only supports vs2010/vs2012.
  • Xamarin Test Cloud: Testing your app to publish your application to the cloud on Xamarin, which automatically helps you test your app on hundreds of of devices.
  • Component Store: The component store, which has a variety of fees/free controls available for download.

And then there's the windows phone that doesn't know where to run ...

Interface Designer

For Android, whether it's Xamarin studio or Xamarin for Visual Studio, there is a designer that makes it easy to design the interface directly, see: http://docs.xamarin.com/guides/ android/user_interface/designer_overview/.

While iOS is not so lucky, Xamarin for Visual Studio does not have a designer. While Xamarin Studio has a designer provided, but currently only available in the Xamarin Studio Alpha version on iOS, it is estimated that the stability is not enough, see: http://docs.xamarin.com/guides/ios/ User_interface/designer/, had to look forward to the future to provide.

You have already installed Xamarin studio or Visual Studio that can be updated directly by switching channels: Http://docs.xamarin.com/recipes/cross-platform/ide/change_ updates_channel/, currently has stable stable version, beta version, and alpha version.

Working style

The android application is compiled into IL code and then JIT-compiled (dynamically compiled) at startup, and a mono runtime is included when the program is published.

iOS, however, compiles the code directly to the arm through AOT compilation (static compilation).

See details: Http://xamarin.com/how-it-works

API documentation

Xamarin provides the API documentation:

    • Android:http://androidapi.xamarin.com/?link=root%3a%2fmonoandroid-lib
    • Ios:http://iosapi.xamarin.com/?link=root%3a%2fmonotouch-lib

Install Xamarin Studio

Xamarin Studio can be downloaded directly from Http://monodevelop.com/Download, and the latest stable version is now 4.0.13.

    • Windows edition relies on the. NET Framework 4.0 and gtk# for. NET 2.12.22 to install Xamarin Studio directly after two dependencies are installed.
    • Mac OSX relies on Mono + gtk# and requires the first download from http://www.go-mono.com/mono-downloads/download.html MRE (mono Runtime) or MDK (mono Developmentkit) installation. Both MRE and MDK contain gtk# and mono.

Android

Android relies on JDK6 and Android SDK, so you need to download it first:

    • Jdk6:http://www.oracle.com/technetwork/java/javase/downloads/jdk6downloads-1902814.html
    • Android SDK and NDK:HTTP://DEVELOPER.ANDROID.COM/SDK, where the NDK is not required.
    • Xamarin.android:http://xamarin.com/download

After installing the JDK and ANDROIDSDK, installing xamarin.android will let you choose whether to install the Visual Studio plugin.

After installing the Visual Studio plugin, set the path to the Android SDK and NDK in the menu tools->options->xamarin->android settings.

Needless to say, Eclipse is too bad to compare with IntelliJ idea, if Android Studio is the best choice for Java development, ADT doesn't have to think about it.

Android Simulator and debugging

Since the emulator provided by the Android SDK is in the big slow, too bad, so have to find a replacement.

Virtual box-based genymotion is definitely the best choice and runs very smoothly, but currently only supports Android4.1.1, 4.2.2.

On the official website: http://www.genymotion.com/registered a good account, and download the installation of Genymotion, the latest version of the current 1.3.0.

You need to install virtual box on your PC before installation (currently the latest version is 4.3.2), but I found that I installed the virtual box 4.3.2 Genymotion Unable to start, so later replaced by the official recommended 4.2.12, from https:// Www.virtualbox.org/wiki/Download_Old_Builds_4_2 download.

After the installation is complete:

  • Via the "Settings" button: Set up the Android SDK path and tick "when a virtual devices starts, connect it automatically to ADB", "ADB from Android Deve Loper Tools successfully found ".
  • Via the "ADD" button
    • Add a device and then need to sign in
    • If the selected device image is not downloaded, you will need to download the vbox image of a device online, with a typical image size of 200M.
    • Add a virtual machine with the wizard prompts, enter a name such as "Lwme Nexus s-4.2.2-with Google apps-api 17-480x800" and wait for the virtual machine to be created.
    • Running a virtual machine from the Play button

After the virtual machine is started, the Xamarin.android toolbar of VS will list the name of the device and you can select the device to debug the Android application on the Genymotion emulator.

IOS on Mac

In Mac OS X to use Xamarin Studio, you must first install Xcode. If you have already installed Xamarin Studio, you can also install Xamarin.ios directly, and then directly develop and debug your iOS application directly from Xamarin Studio.

IOS on Windows

Xamarin.ios is installed directly under Windows, and because there is no emulator under Windows, you need to connect to a Mac emulator for debugging.

Prerequisites are (see: http://docs.xamarin.com/guides/ios/getting_started/installation/mac/):

    • Install and activate Xamarin Studio and Xamarin.ios under Mac
    • Enable Web Proxy (HTTP) in Network->proxies
    • Shutting down the firewall

One of the most important prerequisites is that you must have an iPhone Developer program (IDP) certificate, otherwise there is no way to debug, no need to: https://developer.apple.com/programs/ ios/Application (individual developer $ per year).

After doing the above actions:

  • Tools->options->xamarin->ios Settings->mac Build Host->configure->configure host in Visual Studio Manually
  • Enter the IP address of your Mac and wait for your Mac device to display ready
  • Click the Connect button to connect the device
  • Connection Successful
    • SDK updates may be prompted after a successful connection, select Update, or you will be prompted for a version mismatch cannot connect to Mac
    • Update successful requires re-opening vs

There are two modes of Xamarin.ios Visual Studio plug-in debugging:

    • Real Machine (iphone): By default, you need to connect the iphone to your Mac via USB
    • Simulator (iphonesimulator): Simulator debugging

The iphone is the default and can be changed at Build->configuration Manager's platform, otherwise the iphone will show "no Devices attached" without a connection.

For specific configuration, see: http://docs.xamarin.com/guides/ios/getting_started/introduction_to_Xamarin_iOS_for_visual_studio/.

You can then debug, some situations may mtouch not have permission to run, and you need to chmod +x/developer/monotouch/usr/bin/mtouch to give permission to run.

Visual Studio 2012/2013

The Visual Studio plug-in for Xamarin does not currently support vs 2013, so you'll need to select all 2010 and 2012 when installing Xamarin's vs plugin (as there are only 2013 left in My Computer, Installing VS2013 will also install some VS2010 shells, so the VS plugin will be installed in the VS2010 directory.

Next you need to manually copy some files (if VS2013 is installed on C drive):

  • Copy c:/program Files (x86)/microsoft Visual Studio 10.0/common7/ide/extensions/xamarin to C:/Program Files (x86)/ Microsoft Visual Studio 12.0/common7/ide/extensions/xamarin
  • Copy C:/Program Files (x86)/microsoft the Android directory and iOS directory under the Visual Studio 10.0/common7/ide/projecttemplates/csharp directory to c:/ Program Files (x86)/microsoft Visual Studio 12.0/common7/ide/projecttemplates/csharp
  • Put C:/Program Files (x86)/microsoft Visual Studio 10.0/common7/ide/itemtemplates/ Xamarin.android directory in CSharp directory and iOS ramps copied to C:/Program Files (x86)/microsoft Visual Studio 12.0/common7/ide/itemtemplates/ CSharp
  • Run the C:/Program files (x86)/microsoft Visual Studio 12.0/common7/ide/devenv.exe/setup/nosetupvstemplates Build project and file template cache

The above method is from: http://blog.fire-development.com/2013/07/01/install-xamarin-in-vs-2013-preview-1/, and then by the embarrassing month transformation.

Android and iOS apps can now be developed on the VS2013.

Attached: Software:

Android components:1. JDK 1.6:http://download.xamarin.com/installer/monoforandroid/jdk-6u39-windows-i586.exe 2. Android Sdk:http://dl.google.com/android/installer_r21-windows.exe 3. gtk#: Http://download.xamarin.com/Installer/gtk-sharp-2.12.20.msi 4. Xamarin Studio:http://download.xamarin.com/studio/windows/xamarinstudio-4.0.1.msi 5. Xamarin.android for Visual Studio and Xamarin studio:http://download.xamarin.com/monoforandroid/windows/ Mono-android-4.6.00049.msi

Local offline version Installation instructions:

1. Download and unzip the "Mono for Android offline package" provided by Wule, then "manually" run the following software: 1) jdk-6u45-windows-i586.exe (even if you are a 64-bit system, also install i586 version) 2) Installer_r22.0.1-windows.exe (e.g. installation to D:\Program FILES\ANDROID\ANDROID-SDK)

2, download and unzip the Wule bar provided by the "Android SDK local offline full version", the compressed package of ANDROID-SDK extracted to the above installation path (the path does not contain Chinese): D:\Program files\android\android-sdk

3, set the system environment variable: Right-click My Computer--Properties--Advanced system settings--advanced--environment variables--system variables, find Path, double-click to modify, add: D:\Program files\android\android-sdk\ Platform-tools; (Note that the end must have; English semicolon)

4, in turn, "manual" running installation of the following software: 1) Gtk-sharp-2.12.21.msi//This is required to install Xamarinstudio 2) Xamarinstudio-4.0.8.msi//Use vs201 do not install 3) Mono-android-4.6.07004.msi 4) Mtvs-1.0.897.0.msi//(if you do not develop iOS, this does not need to install, this need to use MFx Patcher.exe hack)

5, install the mono-aundroid crack patch

Crack patch in http://down.51cto.com/data/514411 address will compress package/mandroid folder inside Mandroid.exe put to C:\Program files\msbuild\xamarin\ The Android directory overwrites the source files.

Developing Android Apps with C # in vs2012. Xamarin Environment Building

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.