Matt Matt - 3 months ago 18x
Android Question

Xamarin.Android Support Library

I'm trying to implement James Montemagno's navigation drawer ( and I'm running into issues. When I create a new project, I don't run into any issues, but when I attempt to add the support libraries to an existing project, I get the following error:

The type or namespace name 'Support' does not exist in the namespace 'my namespace' (are you missing an assembly reference)?

Here is my code (The problem code is the very last line. I haven't gone past this because I'd like to understand what's happening):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

using Android.Support.V7.App;
using Android.Support.V4.Widget;
using Android.Support.V4.View;

using MyApp.Parse;
using MyApp.Android.Core.Login;
using MyApp.Android.Core.Utils;

namespace MyApp.Android.Core.Main
[Activity(Label = "MainActivity", Icon = "@drawable/Icon")]
public class MainActivity : BaseActivity
private MyActionBarDrawerToggle mDrawerToggle;
private string mDrawerTitle;
private string mTitle;

private DrawerLayout mDrawerLayout;
private ListView mDrawerListView;
private DrawerMenuAdapter mAdapter;

protected override int LayoutResource
return Resource.Layout.Main;

protected override void OnCreate(Bundle savedInstanceState)

// setup drawer
mTitle = mDrawerTitle = Title;
mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
mDrawerListView = FindViewById<ListView>(Resource.Id.left_drawer);

// create adapter for drawer
mDrawerListView.Adapter = mAdapter = new DrawerMenuAdapter(this);

// set click handler
mDrawerListView.ItemClick += (sender, args) => ListItemClicked(args.Position);

// set DrawerShadow
mDrawerLayout.SetDrawerShadow(Resource.Drawable.drawer_shadow_dark, (int)GravityCompat.Start);

// set DrawerToggle - the animation that happens with the indicator next to the actionbar
mDrawerToggle = new MyActionBarDrawerToggle(this, mDrawerLayout, Toolbar,

// display current fragment's title and update the options menu
mDrawerToggle.DrawerClosed += (o, args) =>
this.SupportActionBar.Title = mTitle;

// display the drawer title and update the options menu
mDrawerToggle.DrawerOpened += (o, args) =>
this.SupportActionBar.Title = mDrawerTitle;

// set the drawer listener

// if first time, click first item
if (savedInstanceState == null)

Button logout = FindViewById<Button>(Resource.Id.logoutButton);

logout.Click += (object sender, EventArgs e) =>
Toast.MakeText(this, APIHandler.Logout(), ToastLength.Long).Show();

int oldPosition = -1;
private void ListItemClicked(int position)
// this way we don't load twice
if (position == oldPosition)

oldPosition = position;

Android.Support.V4.App.Fragment fragment = null;

I'm using Visual Studio and I've tried importing Xamarin.Android.Support.v4 and Xamarin.Android.Support.v7.AppCompat using both Reference and Components within my project. I can find Android.Support when I am 'using' at the beginning of a class, but I cannot locate Android.Support once I'm in the declaration of the class.

Does anyone know how to fix this? I'm new to C#, Xamarin, and Visual Studio, so I'm kind of at a loss.

I know I can fix this by just starting a new project and copying over most of my old code, but I'd like to know why I'm getting this error.


It looks like there actually is a namespace collision with MyApp.Android and Android.Support.etc - to resolve the fragment issue, put this up with the usings:

using Fragment = Android.Support.V4.App.Fragment;

That should resolve the namespace correctly (or you could change your namespace from Myapp.Android, if it becomes too much trouble).