No resource was found that matches the specified name (in 'android: color Primary)

<resources> <!-- inherit from the material theme --> <style name="AppTheme" parent="android:Theme.Material"> <!-- Main theme colors --> <!-- your app branding color for the app bar --> <item name="android:colorPrimary">@color/primary</item> <!-- darker variant for the status bar and contextual app bars --> <item name="android:colorPrimaryDark">@color/primary_dark</item> <!-- theme UI controls like checkboxes and text fields --> <item name="android:colorAccent">@color/accent</item> </style> </resources> 

Try to solve the problem.

+5
source share
3 answers

android:Theme.Material requires API level 21, and therefore it is cleared so that your minSDKVersion below 21.

If you really want to develop an application for API 21, then declare android:minSDKVersion=21 .

And if in case you want to ensure compatibility with a lower version, you need to use the support library , which is usually known as the AppCompat library.

You can access the above attributes using AppCompat:

  <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@color/primary_dark</item> 
+6
source

Actually, you can use this attribute using the support library:

 <style name="AppTheme" parent="@style/Theme.AppCompat.Light"> <item name="colorPrimary">...</item> </style> 

You can also use others:

  <item name="colorPrimaryDark">...</item> <item name="colorAccent">...</item> 
+3
source

android:colorPrimary is only supported from API level 21. You can see the error message in android studio and in eclipse below:

android:colorPrimary requires API level 21 (current minimum is 14) enter image description here

0
source

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


All Articles