Berit Larsen Berit Larsen - 2 months ago 24
Android Question

Xamarin Android: Cannot use ActionBarActivity

I'm having a hard time using ActionBarActivity in my app, as I am unable to import it.
I tried adding Android Support Library 4,7,13 and 17...

Nr.7, 13 and 17 doesn't work, because "Some required packages are not referenced by the project". I haven't figured out what that even means.

Nr.4 doesn't work, because "The type or namespace name 'ActionBarActivity' could not be found (are you missing a using directive or an assembly reference?) C:\progge\Apper\AkvaApp\AkvaApp\AkvaApp\Browser.cs"... even though ActionBarActivity is supposed to be included in the component.

I have built and rebuilt, again and again.

Here's the code:

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.V4;
using Xamarin;

namespace AkvaApp
[Activity(Label = "Browser")]
public class Browser : ActionBarActivity, ActionBar.ITabListener
protected override void OnCreate(Bundle bundle)

ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
ActionBar.Tab tab = ActionBar.NewTab();
tab.TabSelected += (sender, args) =>
Android.Util.Log.Info(this.Class.Name, "this is an info message");
Android.Util.Log.Warn(this.Class.Name, "this is a warning message");
Android.Util.Log.Error(this.Class.Name, "this is an error message");


public void OnTabReselected(ActionBar.Tab tab, FragmentTransaction ft)
throw new NotImplementedException();

public void OnTabSelected(ActionBar.Tab tab, FragmentTransaction ft)
throw new NotImplementedException();

public void OnTabUnselected(ActionBar.Tab tab, FragmentTransaction ft)
throw new NotImplementedException();



I still haven't managed to get it working in Visual Studio, but I did manage in Xamarin Studio. Adding Support Library v7 in Visual Studio did not help at all, but adding it in Xamarin Studio fixed it.

For Xamarin Studio: Right-click the project (not the solution), click Add -> Add NuGet Packages, search for "support library v7", check off the one called AppCompat, and click Add Packages. Then in the class that requires this library, add "using Android.Support.V7;"