I'm trying to use the CoordinatorLayout
in my Xamarin.Android app. I've been using a custom theme with Theme.Material.Light
as its parent, which worked fine before I added the CoordinatorLayout
. When I add it, I get an error telling me I have to use a Theme.AppCompat
theme, but as soon as I do the app fails to build and gives me the following error:
/{project directory}/Resources/values/Styles.xml(0,0):
Error APT0000: Error retrieving parent for item:
No resource found that matches the given name
'@android:style/Theme.AppCompat'. (APT0000) (TnpApp.Android)
This answer suggests installing the major version of the support library that matches the Android SDK I'm using. I've tried this (I think I did everything correctly), but it doesn't help.
Does anyone have any ideas?
I'm using Xamarin Studio on Mac.
UPDATE 1
I tried the following code in MainActivity.cs
in a clean Xamarin.Android project, and build fails with the same error.
namespace ThemeTest
{
[Activity(Label = "ThemeTest", MainLauncher = true, Icon = "@mipmap/icon", Theme = "@android:style/Theme.AppCompat.Light")]
public class MainActivity : Activity
{
// ...
}
}
UPDATE 2
I removed all the folders from /user/.local/share/Xamarin
except for Mono for Android
and zips
as suggested in this answer. I closed Xamarin Studio and reopened it. I tried to deploy the app, and Xamarin reinstalled all the packages but the build failed with the original error.
I was able to fix this problem by simply removing @android:style/
from the style
element's parent
tag in my Styles.xml file. So what looked like this...
<style name="MyCustomTheme" parent="@android:style/Theme.AppCompat">
Now looks like this...
<style name="MyCustomTheme" parent="Theme.AppCompat">
I'm shocked the solution is this simple, but it works. :) I got the idea from this code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With