Bug 29568

Summary: Android 5.1 AppCompat 22.1.1 unable to find theme resources
Product: Android Reporter: Alex Metcalfe <alexander.metcalfe>
Component: GeneralAssignee: dean.ellis
Status: VERIFIED FIXED    
Severity: normal CC: andrew.e.page, brendan.zagaeski, burf2000, dean.ellis, gshackles, guilherme.interfactory, hnoor090, ken.yee, mono-bugs+monodroid, peter.collins, pragma.mobilexp, sadika, v-masang
Priority: Normal    
Version: 5.1   
Target Milestone: 5.1.1 (C5SR1)   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Example project

Description Alex Metcalfe 2015-04-30 00:13:17 UTC
Overview:

After upgrading to Xamarin Android 5.1.0.115 we are unable to build our Android application. It fails trying to load AppCompat resources.

Error:

Resources/values/theme.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.
Resources/values/theme.xml(2): error APT0000: No resource found that matches the given name: attr 'actionModeStyle'.
Resources/values/theme.xml(2): error APT0000: No resource found that matches the given name: attr 'colorAccent'.
Resources/values/theme.xml(2): error APT0000: No resource found that matches the given name: attr 'colorPrimary'.
Resources/values/theme.xml(2): error APT0000: No resource found that matches the given name: attr 'colorPrimaryDark'.
Resources/values/theme.xml(2): error APT0000: No resource found that matches the given name: attr 'logo'.

Xamarin Forum post:

https://forums.xamarin.com/discussion/comment/116792#Comment_116792

Version information:

=== Xamarin Studio ===

Version 5.9 (build 431)
Installation UUID: bd705a5e-cabb-4246-841c-c8683414a35a
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Xamarin.Android ===

Version: 5.1.0.115 (Business Edition)
Android SDK: /usr/local/Cellar/android-sdk/24.0.2
	Supported Android versions:
		4.1    (API level 16)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.10.0.267 (Business Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

=== Operating System ===

Mac OS X 10.10.3
Darwin Alexs-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-30 00:34:11 UTC
If you get a chance, the best way to ensure this bug can be addressed quickly would be to _attach a self-contained test case_ directly on this bug report, along with a short list of _steps to reproduce_.


The last couple of "Additional details" from [1] might be helpful when creating a test case. The information on that article about contacting support might be helpful too.

> [1] https://kb.xamarin.com/customer/portal/articles/1910343-when-and-how-should-i-file-a-bug-report-#note-5
(If this link redirects to the top-level kb.xamarin.com/ page the first time
you click it, try clicking it once more.)


Thanks in advance!
Comment 2 Alex Metcalfe 2015-04-30 03:39:39 UTC
Created attachment 10971 [details]
Example project

Attached project, fails to build with error:

Styles.xml(0,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'. (APT0000) (TestLibrary)
Comment 3 Sadik Ali 2015-04-30 06:09:10 UTC
I have checked this issue and able to reproduce the above behavior with the help of sample  given in the bug description.When I run the project it gives the following build error:

Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'. (APT0000) (TestLibrary)

Screencast: http://www.screencast.com/t/8Sx27fE9Uzg
Ide Logs: https://gist.github.com/sunil360/2ad03affaab70ff93b9b
Build Output: https://gist.github.com/sunil360/45fc8ca013d4d385a4aa

Environment Info:

=== Xamarin Studio ===

Version 5.9 (build 431)
Installation UUID: 0b7eaebc-a0ed-4b58-81df-91e378cad28c
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Apple Developer Tools ===

Xcode 6.2 (6758)
Build 6C107a

=== Xamarin.Mac ===

Version: 2.0.0.262 (Enterprise Edition)

=== Xamarin.Android ===

Version: 5.1.0.115 (Enterprise Edition)
Android SDK: /Users/Admin_Mac/Desktop/Anddk/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: 8.10.0.267 (Enterprise Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

=== Build Information ===

Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

=== Operating System ===

Mac OS X 10.10.2
Darwin Admin-Macs-Mac-mini.local 14.1.0 Darwin Kernel Version 14.1.0
    Thu Nov 13 18:36:56 PST 2014
    root:xnu-2782.10.65~2/RELEASE_X86_64 x86_64
Comment 4 dean.ellis 2015-05-01 07:30:47 UTC
Looks like some of the new Resource Cache targets have introduced this issue. 
In the Xamarin.Android.Common.targets file there are a few targets where we use the 

Condition="'$(AndroidApplication)' != '' And $(AndroidApplication)"

to stop its execution. It was thought at the time that only applications needed to run this code, clearly that is not the case.
Comment 5 dean.ellis 2015-05-01 12:25:31 UTC
Fixed in monodroid/master/d9dfdaae
Comment 6 Alex Metcalfe 2015-05-03 19:24:57 UTC
Hi Dean, Do you have an ETA as to when we can get the fix?

Thanks!
Comment 7 dean.ellis 2015-05-05 04:34:49 UTC
*** Bug 29686 has been marked as a duplicate of this bug. ***
Comment 8 Peter Collins 2015-05-05 17:55:55 UTC
@Dean I'm still able to reproduce this failure against 5.1-series / 162dfcb1:
https://gist.github.com/pjcollins/78104d01e8819b80f968
Comment 9 dean.ellis 2015-05-06 06:09:25 UTC
Looks like the nuget packages were not restored in that test. 

https://gist.github.com/pjcollins/78104d01e8819b80f968#file-gistfile1-txt-L415

probably need to run 

nuget restore -PackagesDirectory ../packages
Comment 10 dean.ellis 2015-05-06 06:09:57 UTC
Alex we are trying to get this into the next service release of Xamarin.Android 5.1
Comment 11 Peter Collins 2015-05-06 12:38:49 UTC
The diagnostic build output previously attached was hastily made, however this issue is still reproducible on both Mac and Windows with the attached project:
https://gist.github.com/pjcollins/face3ef18830f87e7ff3
Comment 12 dean.ellis 2015-05-06 13:33:38 UTC
The error in that output is because @string/hello does not exist. and it is correct it doesn't the library does not have a Strings.xml file with a <string name="hello"></string> in it.
Comment 13 Peter Collins 2015-05-06 14:56:43 UTC
Sorry for the confusion, saw an APT0000 error and didn't fully read the error there...

This has been fixed as of XA 5.1.0.133 / eb7cf862.
Comment 14 guilherme.interfactory 2015-05-06 17:05:38 UTC
I still have this problem. Two work days lost trying to fix this bug and waiting for a Xamarin update. After the update the problem remains.



Xamarin Studio
Version 5.9 (build 431)
Installation UUID: 83078a87-35d7-4ead-b6bd-4bffd795fbfd
Runtime:
	Microsoft .NET 4.0.30319.34014
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

Xamarin.Android
Version: 5.1.0 (Business Edition)
Android SDK: C:\Users\Guilherme\adt-bundle\sdk
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

Xamarin Android Player
Not Installed

Build Information
Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 17:09:09-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

Operating System
Windows 6.2.9200.0 (64-bit)
Comment 15 Peter Collins 2015-05-06 17:08:11 UTC
This fix should be available in the Alpha channel by the end of the week, but is not included in the latest alpha release that was published yesterday.
Comment 16 Madhuri Sangana 2015-06-05 07:36:59 UTC
Hi Team,

I got the above mentioned errors when I am trying to run my android application in visual studio and xamarin studio as well.

My Android SDK is updated to latest lollipop versions i.e Android 5.0.1(API 21) and Android 5.1.1(API 22) are installed.

My Xamarin Studio Version: 5.9.3 (build 1)
Xamarin.Android Version: 5.1.3 (Enterprise Edition)

List of Errors:

D:\G\Myproject\Resources\values\Themes.xml(0,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat'. (APT0000) (Myproject)

D:\G\Myproject\Resources\values\Themes.xml(0,0): Error APT0000: No resource found that matches the given name: attr 'colorPrimary'. (APT0000) (Myproject)

D:\G\Myproject\Resources\values\Themes.xml(0,0): Error APT0000: No resource found that matches the given name: attr 'colorPrimaryDark'. (APT0000) (Myproject)

D:\G\Myproject\Resources\values\Themes.xml(0,0): Error APT0000: No resource found that matches the given name: attr 'dropDownListViewStyle'. (APT0000) (Myproject)

D:\G\Myproject\Resources\values\Themes.xml(0,0): Error APT0000: No resource found that matches the given name: attr 'windowActionBar'. (APT0000) (Myproject)

D:\G\Myproject\Resources\values\Themes.xml(0,0): Error APT0000: No resource found that matches the given name: attr 'windowNoTitle'. (APT0000) (Myproject)

D:\G\Myproject\Resources\values\Themes.xml(0,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name '@style/Widget.AppCompat.ListView.DropDown'. (APT0000) (Myproject)

We tried with adding android v7 support libraries but still we are getting the same errors. Can someone help me out with this issue?

Waiting for response,

Thanks,
Madhuri
Comment 17 Brendan Zagaeski (Xamarin Team, assistant) 2015-06-05 14:33:08 UTC
@Madhuri, thanks for the report.

Unfortunately, it looks like you must be hitting a slightly different issue.




## Next steps



1. Ensure that you have "Project options -> Build -> General -> Target Framework" and "Project options -> Build -> Android Application -> Target Android version" both set to Android 5.0 or higher.



2. If (1) does not solve the problem, please file a _new_ bug report that includes your complete version information as well as a minimal test project that demonstrates the problem.

For additional guidelines for filing a bug see:

> https://bugzilla.xamarin.com/page.cgi?id=bug-writing.html

> https://kb.xamarin.com/customer/portal/articles/1910343-when-and-how-should-i-file-a-bug-report-

(If this link redirects to the top-level kb.xamarin.com/ page the first time you click it, try clicking it once more.)


Thanks in advance!




## Re-verification of test case from comment 2: PASS

I have re-verified the test case from comment 2 using the current stable versions. After removing the problematic "@string/hello" and re-installing the NuGet packages to fix them up (as discussed in the earlier comments on the bug), I was able to build the project without error. 

=== Xamarin Studio ===

Version 5.9.3 (build 1)
Installation UUID: 2c0ea975-8f73-4920-8414-3e9ae359fbf4
Runtime:
	Mono 4.0.1 ((detached/ed1d3ec)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400010044

=== Xamarin.Android ===

Version: 5.1.3.1 (Enterprise Edition)
Android SDK: /Users/macuser/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

=== Operating System ===

Mac OS X 10.10.3
Comment 18 Simon Burfield 2015-06-19 07:06:57 UTC
How does a normal user fix this.

I had a working project and now I get when I try to build my forms app?

/Users/burfies1/BURF/LowlandRescue/Droid/obj/Debug/resourcecache/C1380CFB398E1285B2CD052051C7EFA3/res/values/values.xml(0,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.ActionButton'. (APT0000) (LowlandRescue.Droid)

/Users/burfies1/BURF/LowlandRescue/Droid/obj/Debug/resourcecache/C1380CFB398E1285B2CD052051C7EFA3/res/values/values.xml(0,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'. (APT0000) (LowlandRescue.Droid)

I have check for updates and there are none
Comment 19 Brendan Zagaeski (Xamarin Team, assistant) 2015-06-19 11:56:02 UTC
Please follow the "Next Steps" on comment 17 (after ensuring you have Xamarin.Android 5.1.2 or higher installed on Mac or Xamarin for VS 3.11.586 or higher installed on Windows.)


For further assistance, see:

https://kb.xamarin.com/customer/portal/articles/1632104-how-do-i-contact-xamarin-for-support-

(If this link redirects to the top-level kb.xamarin.com/ page the first time you click it, try clicking it once more.)
Comment 20 Andrew Page 2015-10-28 19:15:52 UTC
I appear to have gotten past this issue(only to run into others, of course)

by running these commands

> cd ~/Library/Developer/Xamarin/android-sdk-mac_x86/
> tools/android update sdk

(and the sdk installed seemed to be several revs out of date.)

After that the build was giving me a "out of memory" error, which was corrected by adding this to the .csproj file:

  <PropertyGroup>
    <JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
</PropertyGroup>

Now I'm back to a network error that was bedevilling me before that doesn't appear on the iOS version of this program.   :(
Comment 21 Malik Noor Hassan 2016-02-03 15:32:26 UTC
Team I have the same problem @madhuri`s first error, I google it ; but nothing is helpful. I have the latest version of Xamarin but, still stuck.. Please guide me
Comment 22 Malik Noor Hassan 2016-02-03 15:35:16 UTC
Hello dearTeam,
 I have the same problem @madhuri`s first error i.e 

D:\microsoft-band-sdk- Error APT0000: No resource found that matches the given name (at 'theme' with value '@style/Theme.AppCompat').

, I google it ; but nothing is helpful. I have the latest version of Xamarin but, still stuck.. Please guide me. My final year project is hanging out due to just this error. Please do something.....
Comment 23 ken.yee 2016-03-10 23:06:31 UTC
FWIW, what fixed it for me was renaming my project's assembly.  It's almost like something got out of sync...