Andres Talavera
Andres Talavera

Reputation: 2200

Xamarin : No resource found that matches the given names (AppCompat)

I deployed a virtual machine on Azure. I've installed Visual Studio 2015, Xamarin and other mobile development tools. I did the same setup on my local computer to test my apps on my devices from Visual Studio

The only difference is the installation of the Android SDK. On my local machine, I have no image system.

Android DSK Manager

I developed an application on my virtual machine. I have no error during compilation. I uses Android.Support.Design, Android.Support.V4, Android.Support.V7.AppCompat, Android.Support.V7.RecyclerView (latest releases from NuGet) and their MvvmCross implementation.

My Azure Virtual Machine

I wanted to continue the development of the application on my local computer. NuGet the packages are properly restored.

When I build app, I have some errors :

My Local Machine

Error       Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.  Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       Error retrieving parent for item: No resource found that matches the given name 'Base.Widget.AppCompat.Button'. Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       No resource found that matches the given name: attr 'buttonStyle'.  Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       No resource found that matches the given name: attr 'colorAccent'.  Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       No resource found that matches the given name: attr 'colorPrimary'. Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       No resource found that matches the given name: attr 'colorPrimaryDark'. Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       No resource found that matches the given name: attr 'windowActionBar'.  Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       No resource found that matches the given name: attr 'windowNoTitle'.    Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error       No resource found that matches the given name: attr 'windowNoTitle'.    Novatech.Droid  D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml

I tried

Could someone explain to me what's the problem? I dropped. Same OS, same tools, same SDK, same JDK,

Upvotes: 17

Views: 34887

Answers (15)

Yksh
Yksh

Reputation: 3306

Navigate to C:\Program Files (x86)\Android\android-sdk\extras\android\support\v7\appcompat.

Open project.properties file.

Change target android to target=android-21.

Upvotes: 1

Tareq
Tareq

Reputation: 1417

Deleting the cache folder in AppData may help

C:\Users\Your-User-name\AppData\Local\Xamarin.Android

Upvotes: 0

James Wierzba
James Wierzba

Reputation: 17498

Try one or all of these in the order given:

  1. Solution wide package restore
  2. Restart visual studio
  3. Clean & Rebuild

It solved the issue for me

Upvotes: 1

Kokul Jose
Kokul Jose

Reputation: 1732

Your compile SDK version must match the support library's major version.

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

Alternatively, you can continue compiling against v22 of the Android SDK by switching to the latest support library v22.

Upvotes: 0

tamj0rd2
tamj0rd2

Reputation: 5670

I had the same problem after moving my project from one folder to another, on exactly the same laptop. I got it working via trial and error and still don't know the cause of the issue. Fixing it involved cleaning the solution a few times and restarting visual studio.

Upvotes: 0

samus
samus

Reputation: 6202

I was getting errors for attributes that were being referenced from styles, so renamed attrs.xml to Attrs.xml (and then back again when the error reoccurred after a clean rebuild).

Upvotes: 0

I had a similar issue when using MSBuild without Visual Studio on a virtual machine. I was trying to build a Xamarin Android project. It kept falling over with the message 'error retrieving parent for item theme.appcompat.light.darkactionbar.' I was able to resolve it by adding the argument /t:restore - for example

msbuild  /t:SignAndroidPackage /t:restore /p:Configuration=Release <project path>

Note the first time I ran it with the restore argument it still failed, but when I tried to build it again it worked. Hopefully this will help someone - it took me a few hours to configure MSBuild properly!

Upvotes: 0

TAHA SULTAN TEMURI
TAHA SULTAN TEMURI

Reputation: 5161

I had the same problem because ,I was using these item in style.xml

  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

but inside color.xml there were no colorAccent defined

<resources>
<color name="primary">#2196F3</color>
<color name="primaryDark">#1976D2</color>
<color name="accent">#FFC107</color>
 <color name="window_background">#F5F5F5</color>
 <color name="splash_background">#3498DB</color>

simply solved by adding

<color name="colorAccent">#3498db</color>

Upvotes: 2

Afzal Ali
Afzal Ali

Reputation: 822

In my case, matching Xamarin.Support version to Target Framework version worked.

For example: If you are targeting 25 API then your Support libraries should also be 25.x..

Upvotes: 0

Boobalan
Boobalan

Reputation: 823

In my case, "Minimum Android Version" API 21, but "Target Android Version" is "use target framework version (API 23)", however it wasn't working earlier, then I've point both the version as API 21 and all of sudden it is started working as expected.

Later I've changed Minimum Android Version is API 21 and Target Android Version as "use target framework version (API 23)"

Upvotes: 5

default
default

Reputation: 571

In my case the problem was that I have a local Nuget Package Server.

Took me a while to realize Xamarin Studio was trying to update the packages from the wrong source.

Upvotes: 0

Adrian C.
Adrian C.

Reputation: 1687

In my case, I was able to fix this problem by adding android-layout-xml.xsd and schemas.android.com.apk.res.android.xsd under XML -> Schemas menu (is accessible only when in a axml file). For the exact location of those files I suggest to do a search on the computer because they aren't in folder of Xamarin as suggested in other answers. In my case they were in the project under obj folder [obj -> Debug -> Schemas ...]

Hope this will help you with your problem.

Upvotes: 0

Nghiem Dao
Nghiem Dao

Reputation: 171

I got the same problem with Xamarin Studio on Mac. What I did to solve the problem is updating the NuGet Package Xamarin.Android.Support.v7.AppCompat. I think you can use the same approach to fix your issue on Visual Studio, too.

Take a look
enter image description here

Upvotes: 13

Nghiem Dao
Nghiem Dao

Reputation: 171

These are steps:

Creating a new app enter image description here

Then right click on "Xamarin.Android.Support.v7.AppCompat", choose "update".

Wait for IDE to finish updating and rebuild the app. enter image description here

Upvotes: 1

Andres Talavera
Andres Talavera

Reputation: 2200

I switched from Xamarin Components to NuGet packages and it works now. MvvmCross installed the latest versions of packages Nuget (23.3.0) for its dependencies (MvvmCross.Droid.Support.V4, MvvmCross.Droid.Support.V7.AppCompat, MvvmCross.Droid.Support.V7.Preference ...). and components used earlier.

I also had to copy the "C:\Users\andres\AppData\Local\Xamarin" folder from my virtual machine.

In Visual Studio, I had no notification about an update available for the components.

Upvotes: 0

Related Questions