# Creating the Android project

Add a new Xamarin Android project with name `MvvmCross.Forms.Droid` into the solution. **DO NOT** select the Android XAML App (Xamarin.Forms) template item.

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQKMXGKCVsoAC83mrl%2F-LPQKZbLOWDZ9_LKKAEc%2Fimage.png?alt=media\&token=dcd492b1-6122-42f0-b3ed-f6c61272932d)

Select the Blank App template:

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQKMXGKCVsoAC83mrl%2F-LPQKcSbudc5mWwlGrcl%2Fimage.png?alt=media\&token=ac366682-e8c5-4c09-96da-6ce6bbc24498)

Install the `Xamarin.Forms` package from the NuGet Package Manageer, or input the command below in the NuGet Manager Console:

```bash
Install-Package Xamarin.Forms
```

Then install the `MvvmCross.Forms` package from the NuGet Package Manager by searching MvvmCross.forms:

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQKMXGKCVsoAC83mrl%2F-LPQKqSR9fd78ckwCVW1%2Fimage.png?alt=media\&token=bde2e725-1c2e-4d72-8cf5-77f7b876b24d)

If you prefer the Package Manager Console, please use this command:

```bash
Install-Package MvvmCross.Forms
```

It will take a while since it need to install some related packages. Next, add the references to both `MvvmCrossDemo.Core` project and `MvvmCrossDemo.Forms.UI` project:

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQKMXGKCVsoAC83mrl%2F-LPQL7cEP_n3kp-GHrHh%2Fimage.png?alt=media\&token=5352cafa-9e3e-464e-8d42-7d98ac2aef5b)

Also, we need to add the reference to `Mono.Android.Export` assembly:

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQKMXGKCVsoAC83mrl%2F-LPQLDdh2ZFSzX68WCwu%2Fimage.png?alt=media\&token=3d363a44-4268-4d78-88df-f21001be3816)

Delete the `activity_main.axml` file in the Resources\layout folder because we use the `MvvmCrossDemo.Forms.UI` project to host the UI.

Open the `MainActivity.cs` file and delete the automatically generated methods and make it to inherit from `MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, UI.App>, Core.App, UI.App>` instead of `AppCompatActivity`, as shown below:

```csharp
using Android.App;
using MvvmCross.Forms.Platforms.Android.Core;
using MvvmCross.Forms.Platforms.Android.Views;

namespace MvvmCrossDemo.Forms.Droid
{
    [Activity(Label = "MvvmCrossDemo.Forms.Droid", Theme = "@style/AppTheme", MainLauncher = true)]
    public class MainActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, UI.App>, Core.App, UI.App>
    {
    }
}
```

The base class of the `MainActivity` shows that the Android project uses the default Setup class to initialize itself. Notice that now we have two App classes, one is in the `MvvmCrossDemo.Core` project, another is in the `MvvmCrossDemo.Forms.UI` project.

Next, we need to define an `AppCompat` theme by adding a new XML file called `styles.xml` into the Resources/values folder. If it already exists, open it and replace the content with the following code:

```markup
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF4081</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF4081</item>
  </style>
</resources>
```

You can find the code of the `style.xml` here: <https://github.com/MvvmCross/MvvmCross/blob/develop/ContentFiles/Forms/AndroidContent/styles.xml.pp>. Because in Android, we use `Toolbar` instead of the `ActionBar` so we must set this item:

```bash
<item name="windowActionBar">false</item>
```

In this file, you can also customize some values for the style of the Android project. Apply this style file by updating the attributes of the `MainActivity` class in the `MainActivity.cs` file, as shown below:

```csharp
[Activity(Label = "MvvmCrossDemo.Forms.Droid", Theme = "@style/MainTheme", MainLauncher = true)]
public class MainActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, UI.App>, Core.App, UI.App>
{
}
```

Now you can launch the `MvvmCrossDemo.Forms.Droid` Project. The result is:

![](https://847068821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPK_0Nj6gmm5SSTHfcs%2F-LPQKMXGKCVsoAC83mrl%2F-LPQM_tjakDKvtchx33F%2Fimage.png?alt=media\&token=a5455a77-1162-42b7-8a73-b18124f69830)
