A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello @Jonathan ,
Thanks for your question.
The error resource attr/colorPrimary not found occurs because MAUI's Android platform uses Material Components themes by default, which require colorPrimary, colorPrimaryDark, and colorAccent to be explicitly defined in your resource files.
You can refer to these following steps:
- Create or update Platforms/Android/Resources/values/colors.xml:
Platforms/Android/Resources/values/colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
</resources>
- Create or update Platforms/Android/Resources/values/styles.xml:
Platforms/Android/Resources/values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
- Select both files in Visual Studio and verify
Build Action = AndroidResource, otherwise Android will not include them in the resource compilation step. - Delete bin/ and obj/ folders, then do a full rebuild solution
If the issue persists, please provide the following details so I can investigate further:
- The full build error log
- Your .csproj file content
Please try and let me know if it works. I'd be happy to investigate further.
I hope this information was helpful. If so, please consider following the guidance to provide your feedback. Thank you.