Android Studio - Render problem solution

If you created a new project and went to activity_main.xml just to see this error:

Render problem
        Failed to load AppCompat ActionBar with unknown error.
        Failed to instantiate one or more classes
        The following classes could not be instantiated:
        - (Open Class, Show Exception, Clear Cache)
        - (Open Class, Show Exception, Clear Cache)
        - (Open Class, Show Exception, Clear Cache)
        Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.
        If this is an unexpected error you can also try to build the project, then manually refresh the layout.
        Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
       Copy stack to clipboard


Then open up your styles.xml, it should look something like this:

<!-- Base application theme. -->
                <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
                <!-- Customize your theme here. -->
                <item name="colorPrimary">@color/colorPrimary</item>
                <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
                <item name="colorAccent">@color/colorAccent</item>


Change line number 2:

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

To this:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">


That's all! Hope it worked.

Enjoyed this article? Give the teacher an apple.




authors profile photo

Articles with similar tags