Xamarin Forms Android - "Resource is not available in the current context"

Viewed 833

When trying to debug my xamarin forms android application, in my MainActivity.cs file I get this error:

CS0103  The name "Resource" not found in the current context D:\MyApp\App\App.Android\MainActivity.cs   12

The code that belongs to this is the following:

TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar; 

When I comment out these lines, it compiles but each page has the title on like half the height of the page instead of inside the title bar. How can I fix this?

2 Answers

Either your project namespace ends with .Android or your namespace is not set the same as it is set in your project settings.

In case you have a namespace like MyApp.Android you should change it to MyApp.Droid.

Related