
The Project Options view
There are numerous options that can be set, which would affect the way the application is built and executed. These options can be adjusted from within the Project Options view. The following section will show you how to use the different options available in the Xamarin Studio project explorer to set various project configurations.
Understanding the project structure
A project is an organizational unit that represents the complete Xamarin Android application in the Solution pad. It contains not just the source code, but also contains the dependent libraries, resources, and other project configurations. Before we begin with writing any code, we must understand the Xamarin.Android project structure and significance of each folder. The following screenshot depicts the different components a Xamarin Android application is composed of:

Xamarin Studio project wizard creates the default project structure and adds the required files and directory to Solution pad. The most important building blocks of a Xamarin.Android project includes:
- The main project (
POIApp
) is the root directory that contains the entire project context. Right-click on the project name to get various options, such as clean, build, run, options for project configurations, and so on. - The
References
directory contains the references to the lists of the base class libraries and assemblies used in the application. Right-click on Edit References to add a base class library or third-party assembly. - The
Components
folder contains reusable pieces of code that are built by community developers and shared on the Xamarin component store. A component gives you the ability to quickly add new controls and functionality to Xamarin applications. For example, if your application uses the database operation, you can quickly integrate the SQLite.Net component to perform SQL operations by writing a few lines of code. We will discuss how to add a component to your application from the Xamarin component store in Chapter 4, Adding a List View. - The
Assets
folder contains the raw assets that can be bundled with the application. It can contain files such as third-party.ttf
fonts, game textures, and so on. - The
Properties
folder generally contains two files: theAndroidManifest.xml
andAssemblyInfo.cs
files. TheAndroidManifest.xml
file contains the metadata of the Android application andAssemblyInfo.cs
contains information about the assembly, such as the name, description, version, and so on. - The
Resources
folder is the main building block composed of images (named as drawables in Android), layout descriptors, strings, colors, themes, and so on. All the resources added are grouped into different folders and are referenced with a unique resource ID.Xamarin Studio automatically creates a new
Resource.designer.cs
file under theResources
directory. This file holds the unique IDs for each resource. This is similar to theR.java
file that is created automatically in the native Android application. This file is maintained by Xamarin.Android and is periodically regenerated whenever there is a change made to the application's resources.The following are some of the subdirectories you can create inside the
Resources
directory:- Resources/drawable-xxx: The drawable folders are used to hold the images such as
.png
,.jpeg
, and so on. Notice that the default project structure contains multiple drawable folder suffixes with qualifiers, such as hdpi, mdpi, xhdpi, and so on. The qualifier indicates that the resources inside that directory will be used in certain circumstances only. You can create another directoryResources/drawable
to place the images that are not required for different device configurations.A more detailed discussion on resource qualifiers are explained in Chapter 7, Designing for Multiple Screen Sizes.
- Resources/layout: This folder contains the XML layout descriptor files. In our example, the
Main.axml
file is created. - Resources/values: This folder contains files, such as
string.xml
, to declare all the strings used in an app. This is helpful for app localization. - Resources/menu: The menu folder holds the XML-based menu specification for each activity.
- Resources/drawable-xxx: The drawable folders are used to hold the images such as
- The application source code can be managed inside multiple different folders. By default, the Xamarin Studio project template is created in the
MainActivity.cs
file. - The newer version of Xamarin Studio creates the
Xamarin.UITest
project, which is used for automated UI acceptance testing. TheXamarin.UITest
framework is based on Calabash, using which you can write a test case in C# and NUnit and execute for both the Android and iOS platforms. This book covers Android unit testing using NUnitLite in Chapter 8, Creating Data Storage Mechanisms. For now, if you wish, you can safely delete the test project.