问题
I've created a basic xamarin.forms
project (with PCL code sharing strategy) and I'm getting error for the following two lines in MainActivity::OnCreate()
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
CS0117 'Resource.Layout' does not contain a definition for 'Tabbar'
CS0117 'Resource.Layout' does not contain a definition for 'Toolbar'
The resource files exist as Resources\layout\Tabbar.axml
and Resources\layout\Toolbar.axml
and the build action for both of them is set to AndroidResource
.
I suspect there is something wrong with my android SDK installation. Currently the following packages are installed:
But the Run
button in Visual Studio 2015 still is showing Android 6.0 API 23
and it's not possible to change it:
I've also set the Target Framework
version of the Android project to 7.1:
The project structure is as the following:
I've followed this tutorial step by step to create the sample project.
How can I get the error fixed?
回答1:
The problem seems in API installed. It is still a little mystery for me which APIs must be installed but deleting the build tools 24 and installing build tools 26.0.1 fixed the issue for build.
Then installed NDK which was missing and set path in Xamarin options. Now 2 options are available for computers supporting HAXM and/or Hyper-V
- HAXM. Disable Hyper-V. Then change emulator setting in AVD manager which were not created and download an Itom image for emulator using Android SDK. Download and install HAXM. You are ready.
- Enable Hyper-V. Download and install Hyper-V VS emulators. Run it and create emulator(s) virtual machine(s). You are ready.
Run your app.
来源:https://stackoverflow.com/questions/45393794/xamarin-resource-layout-does-not-contain-a-definition-for-tabbar-error