Error getting parent element for element: resource not found that matches the specified name "Android: Theme.Material"

I am trying to use material Theme with the 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> 

In doing so, I get the following error:

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

What is wrong with that?

0
source share
3 answers

Follow these steps 1. First of all, define a new xml file in the name of the res / values ​​folder (color.xml). 2. Then define your own color as.

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

The problem is that your theme provided a place for customization, but it does not know @ color / primary this thing.

try to start the project again.

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

+2
source

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

You need to follow these steps.

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

Read more about Create a project using Andoid L

0
source

@Pankaj's answer was correct at the time of writing. API 21 is now officially released and something has changed.

To use the Material Theme in your project, you must:

  • use API 21 to compile (required)

Then you can choose one of the following options:

  • use the minSdkVersion = 21 command and the value folder

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

  • use the AppCompat folder in the values ​​folder.

0
source

Source: https://habr.com/ru/post/1206695/


All Articles