Basics of Xamarin

Nowadays, I am slowly migrating towards 100 percent Xamarin-based development. I am sharing my knowledge of what I have learned so far.

In this article, you will learn the following things.

  1. What is Xamarin?
  2. How to install Xamarin with Visual Studio(VS) 2015?
  3. Xamarin Native vs Xamarin Form.
  4. Introduction to Project Structure.

What is Xamarin?

Xamarin is the set of tools that allows us cross-platform mobile application development with C# language (.NET). We can develop the Smartphone apps for Android, iOS, and Windows. Xamarin was owned by Microsoft in March 2016 and was integrated freely with Visual Studio. Before integration, people used Xamarin Studio for development purposes.

Xamarin has the following platforms.

  1. Xamarin.Mac - MonoMac
  2. Xamarin.iOS - MonoTouch
  3. Xamarin.Android - MonoDroid

These are standalone tools for cross-platform development and you can separately develop projects for the above platforms. With the help of Xamarin, you can use all the power of .NET (C#) all the way. For detailed history, journey, and success of Xamarin, please refer this link.

How to install Xamarin with Visual Studio 2015?

I did the installation in this way.

  • First, installed Visual Studio 2015 completely (because Xamarin installation takes too much time for installation, depending on your internet speed.)

    Or

    You can select CUSTOM installation, and select Xamarin and Android SDK components.

After installation of VS2015, open Control Panel >> Program and Features.

Select Microsoft Visual Studio Enterprise 2015 and double click on it.

Microsoft Visual Studio Enterprise 2015

The following screen will appear.

screen

Select Modify.

Select the following items.

  1. Cross Platform Mobile Development under
    (select) C# / .NET (Xamarin v4.1.1)

  2. Common Tools and Software Development Kits under
    (select Appropriate bits options as per your machine),

    1. Android Native Development Kit
    2. Android SDK
    3. Apache Ant
    4. Java SE development KIT.

       Development Kit

       Development Kit

If You search on the internet, following are the ideas for installation.

  • https://msdn.microsoft.com/en-in/library/mt613162.aspx
  • http://www.infragistics.com/community/blogs/blagunas/archive/2014/11/14/installing-xamarin-for-visual-studio-2015-preview-side-by-side-with-visual-studio-2013.aspx
  • http://stackoverflow.com/questions/30913859/how-to-install-xamarin-for-visual-studio-2015-when-visual-studio-2013-is-install

Xamarin Native vs Xamarin Forms

Xamarin Native

  1. As native word defines itself, it's used more for Android Framework API or code.
  2. Better native UI.
  3. Code Sharing

Xamarin Forms

  1. Xamarin’s own custom control and very helpful to design FORM - Dataentry form.
  2. Requires lesser knowledge of Android Framework.
  3. Fast development as compared to the Native.

For further understanding, go through the following links.

  • http://stackoverflow.com/questions/36899096/should-i-choose-xamarin-native-or-xamarin-forms-for-existing-android-app/36900563
  • http://willowtreeapps.com/blog/xamarin-vs-native-app-development/
  • http://blah.winsmarts.com/2014-2-HTML5_vs_PhoneGap_vs__Xamarin_vs_Native.aspx
  • https://www.xamarin.com/forms

    best

Introduction to Project Structure

Create a new project by selecting Visual C# ---> Android ---> Blank App(Android) Native App structure.

Project Structure

After creating a new project, the screen will look like this.

project

In Solution Explorer, you can see the following structure.

solution explorer

  1. Properties- It contains configuration detail of project. There are two main files,

    • AndroidManiFest.xml- Configuration file. Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest file provides essential information about your app to the Android system, which the system must have before it can run any of the app's code.

    • AssemblyInfo.cs- Assembly Information.

  2. References- All the references which point to this project.
  3. Components- Any external components added to the project will display under this category.
  4. Assets- This is an empty folder. Whatever files you keep here, are copied inside APK package, more freedom to store files.
  5. Resources-  As name defines itself, resources are the content of app. Following are the sub folders of Resources,

    • Drawable- To store image for different resolution sizes.
    • Layout- UI files of app.
    • Values- string.xml, style.xml

  6. MainActivity.cs- This is the main file to load the app. Every activity points to one UI file, like Main.XML is linked with MainActivity.cs.

In the next article, I will show you how to code.


Similar Articles