Rendering Problems with WindowDecorActionBar
This brief article describes the android.support.v7.app.WindowDecorActionBar error that is displayed when an App's layout is viewed in Studio. A null pointer exception occurs when Android Studio attempts to show a layout in design mode after a project has been built.
The error is easy to reproduce. Simply create a new project with an empty Activity
. Run the project. Open the Activity's layout in Design view and the error is shown:
Rendering Problems
The following classes could not be displayed:
- android.support.v7.app.WindowDecorActionBar (Open Class, Show Excpetion, Clear Cache)
... etc.
The cause is a null pointer exception:
java.lang.NullPointerException
at android.support.v7.app.WindowDecorActionBar.getDecorToolbar(WindowDecorActionBar.java:240)
at android.support.v7.app.WindowDecorActionBar.init(WindowDecorActionBar.java:197)
at android.support.v7.app.WindowDecorActionBar.<init>(WindowDecorActionBar.java:189)
... etc.
Strangely clicking the Clear Cache link on the displayed error resolves it. As does opening and closing the project or Studio.
Another workaround from Stack Overflow is to edit styles.xml in the values folder. Add Base. in front of Theme.AppCompat.Light.DarkActionBar, i.e.:
parent="Theme.AppCompat.Light.DarkActionBar"
becomes:
parent="Base.Theme.AppCompat.Light.DarkActionBar"
Author:Daniel S. Fowler Published: