简体   繁体   English

错误 CS0234 命名空间“Xamarin.Forms.Platform”中不存在类型或命名空间名称“Android”

[英]Error CS0234 The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform

When I create a new blank cross-platform project in Visual Studio 2017 I get about six errors.当我在 Visual Studio 2017 中创建一个新的空白跨平台项目时,我收到大约六个错误。 All on 'MainActivity.cs' page.全部在“MainActivity.cs”页面上。 I'm running VS2017 that updated to support Core 2.1.我正在运行更新为支持 Core 2.1 的 VS2017。 I'm not sure what I need to install or change to fix this.我不确定我需要安装或更改什么来解决这个问题。

I'm using我正在使用

C:\\Program Files\\Java\\jdk1.8.0_171 C:\\Program Files\\Java\\jdk1.8.0_171

C:\\Program Files (x86)\\Android\\android-sdk C:\\Program Files (x86)\\Android\\android-sdk

and under tools and extensions, everything is up to date.在工具和扩展下,一切都是最新的。

   namespace HelloWorld.Droid
{
[Activity(Label = "HelloWorld", Icon = "@mipmap/icon", Theme = 
"@style/MainTheme", MainLauncher = true, ConfigurationChanges = 
ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
      public class MainActivity : 
global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    }
}
}

errors(I get these errors every time I create a blank project)错误(每次创建空白项目时都会收到这些错误)

Error CS0103 The name 'LoadApplication' does not exist in the current context Error CS0234 The type or namespace name 'Android' does not exist in the namespace Error CS0115 'MainActivity.OnCreate(Bundle)': no suitable method found to override Error CS0103 The name 'ToolbarResource' does not exist in the current context Error CS0103 The name 'TabLayoutResource' does not exist in the current context Error CS0234 The type or namespace name 'Forms' does not exist in the namespace 'Xamarin.Forms'错误 CS0103 当前上下文中不存在名称“LoadApplication” 错误 CS0234 命名空间中不存在类型或命名空间名称“Android” 错误 CS0115“MainActivity.OnCreate(Bundle)”:找不到合适的方法来覆盖错误 CS0103当前上下文中不存在名称“ToolbarResource”错误 CS0103 当前上下文中不存在名称“TabLayoutResource”错误 CS0234 命名空间“Xamarin.Forms”中不存在类型或命名空间名称“Forms”

I'm new to Xamarin and I tried to add references to my project but I'm not sure which of the 3 projects to add references or what references I need.我是 Xamarin 的新手,我尝试添加对我的项目的引用,但我不确定要添加引用的 3 个项目中的哪一个或我需要哪些引用。

In the end, doing the below solved the issue:最后,执行以下操作解决了问题:

what I did was went to help in VS2017 and updated to 15.9.6 and it recommended an update to Android SDK .我所做的是去帮助VS2017并更新到15.9.6并推荐更新到Android SDK So I updated it all and cleaned and rebuild project and that fixed the issue.所以我更新了所有内容并清理并重建项目并解决了问题。 When I first ran the project it told me some Android references need updating and I updated from the error list and in the NuGet panel.当我第一次运行该项目时,它告诉我一些Android references need updating ,我从错误列表和NuGet面板中进行了更新。 And it worked它起作用了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误 CS0234 命名空间“Microsoft”中不存在类型或命名空间名称“Reporting”(您是否缺少程序集引用?) - Error CS0234 The type or namespace name 'Reporting' does not exist in the namespace 'Microsoft' (Are you missing an assembly reference?) 错误CS0234:名称空间“System.Runtime.InteropServices”中不存在类型或命名空间名称“CustomMarshalers” - Error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the namespace 'System.Runtime.InteropServices' 错误CS0234类型或名称空间名称'SendTextMessageAsync'在名称空间'Telegram.Bot'中不存在 - Error CS0234 The type or namespace name 'SendTextMessageAsync' does not exist in the namespace 'Telegram.Bot' 错误CS0234名称空间名称'编码'不存在 - ERROR CS0234 namespace name 'Encodings' does not exist 错误 CS0234:命名空间“Microsoft”中不存在类型或命名空间名称“Azure”(您是否缺少程序集引用?) - error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) 错误 CS0234:命名空间“MvcMovie”中不存在类型或命名空间名称“Data” - error CS0234: The type or namespace name 'Data' does not exist in the namespace 'MvcMovie' 错误CS0234:类型或名称空间名称'AccountManagement'在名称空间'System.DirectoryServices'中不存在 - error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' 错误 CS0234 命名空间“MvvmCross”中不存在类型或命名空间名称“平台”(您是否缺少程序集引用?) - Error CS0234 The type or namespace name 'Platforms' does not exist in the namespace 'MvvmCross' (are you missing an assembly reference?) 错误 CS0234:命名空间“System.Data”VSTS (DevOps) 中不存在类型或命名空间名称“实体” - Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' VSTS (DevOps) 错误 CS0234:命名空间“System.Web”中不存在类型或命名空间名称“脚本” - error CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM