user3371398
user3371398

Reputation: 477

Error retrieving parent for item: No resource found that matches the given name 'Android:Theme.Material'

I am trying to use material Theme with following code

My styles.xml file

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="Android:Theme.Material">
        <item name="android:colorPrimary">@color/primary</item>

    </style>

</resources>

While doing this i am getting following error :

Error retrieving parent for item: No resource found that matches the given name 'Android:Theme.Material'  

What is wrong with this?

Upvotes: 0

Views: 3829

Answers (3)

Pankaj Kumar
Pankaj Kumar

Reputation: 82948

Set android:minSdkVersion="L" android:targetSdkVersion="L".

You need to do following steps

  • compileSdkVersion is set to 'android-L'
  • minSdkVersion is set to 'L'
  • targetSdkVersion is set to 'L'

Read more about Create a Project using Andoid L

Upvotes: 0

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363687

The @Pankaj answer was correct at time of writing. Now API 21 are officially released, and something is changed.

To use the Material Theme in your project you have to:

  • use API 21 to compile (it is required)

Then you can choose one of these:

  • use the minSdkVersion=21 and values folder

  • use the Theme.Material only in values-v21 folder.

  • use the AppCompat Theme in values folder.

Upvotes: 0

Vivek Pal
Vivek Pal

Reputation: 181

Follow these steps 1. first of all define a new xml file in your res/values folder name(color.xml). 2. then define your custom color as.

<resources>
<color name="primary">#03f</color>
</resources>

The problem is that your theme has provided a place to customize but it does not know @color/primary this thing.

now try again to run the project.

remember Set android:minSdkVersion="L" android:targetSdkVersion="L"

Upvotes: 2

Related Questions