简体   繁体   English

设置Xamarin.Forms-“找不到与给定名称匹配的资源...”

[英]Setup Xamarin.Forms - “No resource found that matches the given name…”

I'm trying to build a new Visual Studio project from the Xamarin.Forms (PCL, C#) projects template and I get some "No resource found that matches the given name..." errors from the "styles.xml" file. 我试图从Xamarin.Forms(PCL,C#)项目模板构建一个新的Visual Studio项目,并且从“ styles.xml”文件中收到一些“找不到与给定名称匹配的资源...”错误。

1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(3): error APT0000: No resource found that matches the given name: attr 'colorAccent'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(2): error APT0000: No resource found that matches the given name: attr 'colorPrimary'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(2): error APT0000: No resource found that matches the given name: attr 'colorPrimaryDark'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(2): error APT0000: No resource found that matches the given name: attr 'windowActionBar'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(4): error APT0000: No resource found that matches the given name: attr 'windowActionModeOverlay'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(2): error APT0000: No resource found that matches the given name: attr 'windowNoTitle'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(4): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'.
1>c:\users\[...]\documents\visual studio 15\Projects\XamForm041105\XamForm041105\XamForm041105.Droid\Resources\values\styles.xml(4): error APT0000: No resource found that matches the given name: attr 'colorAccent'.

I noticed this is a common problem for Xamarin users lately, but I couldn't find a working solution for my project. 我最近注意到这是Xamarin用户的常见问题,但是我找不到适合我项目的可行解决方案。 So, how should I setup my project in order for Xamarin.Forms to work ? 因此, 如何设置项目才能使Xamarin.Forms工作

This is my current configuration, is there something I should try and chang e? 这是我当前的配置, 是否应该尝试更改

Visual Studio Enterprise 15 Preview 5
Xamarin Forms v2.3.2.127
Xamarin.Android.Support Library v23.3.0
Java jdk 1.8.0_92
Android NDK r11c
Android SDK Tools 25.2.2
Android SDK Platform-tools 25
Android SDK Build-tools 23.0.3
Android SDK Platform 23.3
Google APIs 23.1
Sources for Android SDK 23.1

Notice that - after reading this post - I downgrade my Android SDK Build-tools from 24 to 23 (and it's not working) but I also tried a lot of Android SDK Build-tools vs API combination but none worked. 请注意,在阅读了这篇文章之后 ,我将Android SDK Build-tools从24降级到了23(并且无法正常工作),但是我也尝试了很多Android SDK Build-tools与API的组合,但是都没有用。

So, I figured this issue out. 所以,我想出了这个问题。 If someone should have this same problem in the future and couldn't solve it implementing the solutions you can find online, here's another tip. 如果将来有人遇到同样的问题,并且无法解决您可以在网上找到的解决方案,那么这里还有另一个提示。

SOLUTION: following the "Solution 2" in the post I linked in my question, download the android_m2repository_r29.zip file and put in in the %localappdata%\\Xamarin\\Xamarin.Android.Support.Animated.Vector.Drawable folder (but my guess is one folder is as good as another). 解决方案:按照我在问题中链接的帖子中的“解决方案2”,下载android_m2repository_r29.zip文件,并将其放入%localappdata%\\ Xamarin \\ Xamarin.Android.Support.Animated.Vector.Drawable文件夹中(但我猜是这样)一个文件夹和另一个文件夹一样好)。 Then rebuild the Droid project. 然后重建Droid项目。 That's it! 而已! (At the end of the process, you can delete the zip in the folder) (在该过程结束时,您可以删除文件夹中的zip)

On OSX/MacOS: the folder is located in /Users/[UserName]/.local/share/Xamarin 在OSX / MacOS上:文件夹位于/Users/[UserName]/.local/share/Xamarin

There can be couple of reasons 可能有几个原因

1.) Theme.Appcompat is in Xamarin.Android.Support.v7.AppCompat package and seems like it is missing in your SDK so you need to update your SDK appcompat package 1.) Theme.Appcompat位于Xamarin.Android.Support.v7.AppCompat程序包中,似乎在您的SDK中丢失,因此您需要更新SDK appcompat程序包

2.) Your compile SDK and support SDK versions are different so they need to be same 2.)您的编译SDK和支持SDK版本不同,因此它们必须相同

eg if you are using support library v23, you need to compile against Android SDK of v23. 例如,如果您使用的是支持库v23,则需要针对v23的Android SDK进行编译。

3.) Simple build issue , so you can delete [path_to_loc\\\\AppData\\Local\\xamarin] and rebuild your project (better take a backup for safety) 3.)简单的构建问题,因此您可以删除[path_to_loc\\\\AppData\\Local\\xamarin]并重建您的项目(为安全起见最好进行备份)

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

相关问题 在Xamarin.Android中找不到与给定名称匹配的资源(在'headerLayout'处) - No resource found that matches the given name (at 'headerLayout') in Xamarin.Android Xamarin.Forms 资源文件未找到 - Xamarin.Forms Resource file is not found 在资源字典异常中找不到键-Xamarin.Forms - Key is not found in resource dictionary Exception - Xamarin.Forms Xamarin-检索项目的父项时出错:找不到与给定名称'Theme.AppCompat.Light.DarkActionBar'匹配的资源 - Xamarin - Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar' 找不到Xamarin.forms命名空间 - Xamarin.forms namespace not found 如何修复Xamarin android c#中的“找不到与给定名称(在'value'处与值'@ integer / google_play_services_version匹配)的资源” - How to fix“No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version)” in Xamarin android c# 系统找不到,Xamarin.Forms 找不到 - System could not be found, Xamarin.Forms not found 没有找到与给定名称匹配的资源,我在哪里做错了? - No resource found that matches the given name, where I do something wrong? 使用Xamarin.Forms的MvvmCross:未调用安装程序 - MvvmCross with Xamarin.Forms: Setup not called 找不到与给定名称Styles.xml匹配的资源 - No resource found that matches the given name Styles.xml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM