dcousens dcousens - 1 year ago 221
Java Question

No resource found that matches the given name: attr 'colorPrimaryDark'

error: Error: No resource found that matches the given name: attr

And for
, and
This is a bare-bones project, targeting version 21+.

For posterity, see my


<style name="AppTheme" parent="android:Theme.Material">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>


<?xml version="1.0" encoding="utf-8"?>
<color name="primary">#3F51B5</color>
<color name="primary_dark">#303F9F</color>
<color name="accent">#FF4081</color>


apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.dcousens.myapplication"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"

.. snip

There are many questions under this name, but the resolutions for them are bumping
to at least 21.
This has already been done, and the error persists.

Answer Source

If you are using android:Theme.Material, rather than the suggested Theme.AppCompat, you must use the android: prefix on each item.

<style name="AppTheme" parent="android:Theme.Material">
  <item name="android:colorPrimary">@color/primary</item>
  <item name="android:colorPrimaryDark">@color/primary_dark</item>
  <item name="android:colorAccent">@color/accent</item>

Using AppCompatActivity and Theme.AppCompat is recommended for all API levels as things have continued to change since API 21 and AppCompat continues to add fixes up through even API 24.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download