Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No resource found that matches the given name 'android:Theme.Material'

After reading this answer, I made RecyclerView ran it on Android 3.0+. But styles.xml in values-v21 still causes the error.

Theme.

<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">

    <!-- Main theme colors -->
    <!-- your app's branding color (for the app bar) -->
    <item name="android:colorPrimary">#f00</item>
    <!-- darker variant of colorPrimary (for status bar, contextual app bars) -->
    <item name="android:colorPrimaryDark">#0f0</item>
    <!-- theme UI controls like checkboxes and text fields -->
    <item name="android:colorAccent">#00f</item>
</style>

Error.

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

I need to support Android versions from Android 3.0.x (API level 11). <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" /> is not a solution.

like image 741
Maksim Dmitriev Avatar asked Oct 20 '22 02:10

Maksim Dmitriev


2 Answers

android:Theme.Material is supported only from API level 21. You can see the error message in android studio as below:

android.Theme.Material requires API level 21(current min is 14)
like image 116
Psypher Avatar answered Oct 23 '22 01:10

Psypher


If you use the support library, you can safely use those attributes, and they will work (as much as the OS allows) :

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

    <item name="colorPrimary">...</item>
</style>

You can also use the others:

    <item name="colorPrimaryDark">...</item>
    <item name="colorAccent">...</item>
like image 42
android developer Avatar answered Oct 23 '22 02:10

android developer