49

Ever since upgrading to the latest appcompat library, I'm seeing a message in my logs from ViewUtils.

app:theme is now deprecated. Please move to using android:theme instead.

I'm using parent="Theme.AppCompat.Light.NoActionBar" as my theme parent.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
spierce7
  • 14,797
  • 13
  • 65
  • 106

4 Answers4

73

Replace app:theme to android:theme but you can have a situation when you are not using app:theme. Check your layout, especially toolbar layout. In my case, I didn't have app:theme in my layout files. Then take a look at my situation:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:styled="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar_actionbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    styled:popupTheme="@style/ToolbarDarkPopup"
    styled:theme="@style/ActionBarThemeOverlay" />

And I've changed this layout to:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_actionbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ActionBarThemeOverlay" />

Now I don't see the warning.

Take a look also here: https://chris.banes.me/2015/04/22/support-libraries-v22-1-0/

Great explanation by Chris Banes

timakden
  • 64
  • 1
  • 2
  • 10
adek
  • 3,045
  • 2
  • 27
  • 41
  • and what about 'popupTheme'? should we also use 'android' instead of 'styled'? – BamsBamx May 23 '15 at 22:47
  • @BamsBamx No, you keep using styled:popupTheme, styled:contentInsetStart, etc. (as long as you're using the support library Toolbar). These are styleable attributes declared by the support library. – sorianiv May 29 '15 at 10:07
  • 1
    But this solutions works with every version of Android or there is any version which don't accept the use of andoid:teme? – Pau Arlandis Martinez Sep 21 '16 at 06:57
  • 1
    @PauArlandisMartinez this has a bit more information: https://stackoverflow.com/questions/57279615/what-is-the-difference-b-w-apptheme-androidtheme-in-android-programming – riQQ Apr 21 '21 at 18:04
19

I had another case where this occurred when my Toolbar was styled in styles.xml. It looked like this:

<style name="AppActionBar" parent="Widget.AppCompat.ActionBar">
    <item name="android:background">@color/ng_blue</item>
    <item name="theme">@style/ThemeOverlay.AppActionBar</item>
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>

Change name="theme" to name="android:theme" and it fixed the problem.

Greg Ennis
  • 14,917
  • 2
  • 69
  • 74
  • that was the place my search for `:theme` did not find as I just did not think about this location... – prom85 Oct 20 '15 at 13:06
16

Check your layout.

You are using a Toolbar where you have defined app:theme.

Now with the support 22.1 app:theme is deprecated. You should use android:theme

Check here for more info.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
1

If you see a code block like the following in the styles file ;

<item name="theme">@style/MyToolbarTheme</item>

Replace it.

<item name="android:theme">@style/MyToolbarTheme</item>
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Erhan Biçer
  • 122
  • 6