简体   繁体   中英

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.

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. So, how should I setup my project in order for Xamarin.Forms to work ?

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.

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). Then rebuild the Droid project. That's it! (At the end of the process, you can delete the zip in the folder)

On OSX/MacOS: the folder is located in /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

2.) Your compile SDK and support SDK versions are different so they need to be same

eg if you are using support library v23, you need to compile against Android SDK of v23.

3.) Simple build issue , so you can delete [path_to_loc\\\\AppData\\Local\\xamarin] and rebuild your project (better take a backup for safety)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM