Reputation: 825
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
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.
Upvotes: 14
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:
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;
}
if (this.mBuilder.isThemeAppCompat())
then change to :
if (this.mBuilder.isThemeAppCompat() && hasWindowDecorActionBar(params))
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
Reputation: 151
Click on Theme in Editor and change the theme:
MY issue is solved after this
Upvotes: 2
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
Change the Theme if first solution not work
Upvotes: 7
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
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
You probably need to update your tools
Upvotes: 78