Marche101
Marche101

Reputation: 825

Exception raised during rendering: Unable to find the layout for Action Bar

While using Android Studio just now I was editing an XML file in the editor and I got this error in the Preview and Design windows:

 Exception raised during rendering: Unable to find the layout for Action Bar.

I've tried restarting Android Studio, my Laptop and Googling for the answer but I can't find anything. Has anybody experienced anything similar?

Upvotes: 28

Views: 19828

Answers (7)

Sergey
Sergey

Reputation: 1050

Those using Eclipse might try to choose Theme.DeviceDefault to eliminate the exception. Update: as per comments this works for Android Studio also. enter image description here

Upvotes: 14

luk
luk

Reputation: 11

I had this error on eclipse-3.8, adt-23.07, sdk-tools-23.1, appcompat_v7_r19.1.

After analyzing the error I found the problem is in android-sdk-linux/platforms/android-23/data/layoutlib.jar:com/android/layoutlib/bridge/impl/Layout.class on method createActionBar at line if (this.mBuilder.isThemeAppCompat())

My solution:

  1. (don't have the source, so) decompile Layout.class -> Layout.java
  2. edit Layout.java, add method:


    private boolean hasWindowDecorActionBar(SessionParams params) {
        LayoutlibCallback callback = params.getLayoutlibCallback();
        try {
            callback.findClass("android.support.v7.app.WindowDecorActionBar");
        } catch (ClassNotFoundException ei) {
            try {
                callback.findClass("android.support.v7.internal.app.WindowDecorActionBar");
            } catch (ClassNotFoundException e) {
                return false;
            }
        }
        return true;
    }

  1. Locate the line if (this.mBuilder.isThemeAppCompat()) then change to :

    if (this.mBuilder.isThemeAppCompat() && hasWindowDecorActionBar(params))

  1. recompile Layout.java -> Layout.class and Layout$Builder.class
  2. update layoutlib.jar with the new classes
  3. restart eclipse

That's all. Now, I can render using API-23 all of my old app layouts that links against appcompat_v7_r19.1.

Upvotes: 1

Kushal Ramola
Kushal Ramola

Reputation: 151

Click on Theme in Editor and change the theme:

click on theme in editor and change the theme

MY issue is solved after this

Upvotes: 2

Adiii
Adiii

Reputation: 60016

You can solve this problem by two ways

Change API from the tab, Try one of them from the available or Select PICK UP BEST or change your minimum sdk

Select API from the available

Change the Theme if first solution not work

enter image description here

Upvotes: 7

Boody
Boody

Reputation: 144

i think it is a bug and there is no ultimate solution until this moment, changing to API less than API-22 is a temp solution not more.

Upvotes: -1

Glenn
Glenn

Reputation: 12809

I had this kind of error. On My Mac, there is API 22. If I choose it this error will appear. So clicking on API 21 or below would solve your problem

enter image description here

You probably need to update your tools

Upvotes: 78

Patel Hiren
Patel Hiren

Reputation: 305

You suppose to do clean project.

Upvotes: 0

Related Questions