76

When I add android.support.v7.widget.Toolbar or another android.support.v7.widget.* there are rendering problems.

But Support Library is up to date. And I complied in dependecies properly. I can import them in MainActivity.java

What is the problem?

Brendan Green
  • 11,676
  • 5
  • 44
  • 76
Zhambulable
  • 1,083
  • 2
  • 10
  • 17

11 Answers11

200

UPDATE: Apparently they have fixed this bug in the final Android Studio 1.3 release (according to users reporting this issue solved in the issue tracker: https://issuetracker.google.com/issues/37043358).

This is a known bug since Android Studio build 1.1, which still exists in AS versions 1.2 and 1.3 beta. Switching the preview's API level from 22 to 21 fixes the for most people. While waiting for a fix you could try it as well.

Android Studio Layout Preview - Switch API to 21

UPDATE: This is already reported as a known issue of Android Studio (http://tools.android.com/knownissues#TOC-Can-t-Render-Layouts-in-Android-Studio-1.2)

Cœur
  • 37,241
  • 25
  • 195
  • 267
david.schreiber
  • 3,851
  • 2
  • 28
  • 46
96

I don't know if this will help or not, but I was creating a test project (direct from the wizard, no custom code) and getting this error. Trying to modify the project structure and find the missing class didn't help.

The build failed with the following error:

***rendering problems

The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout***

Obviously it's not the final solution, but changing the Theme in design view from the base "project theme" to anything else allows it to build.

Zeus56
  • 1,861
  • 14
  • 9
  • not is a solution final, but is a good idea :) and works, but How I can fix correctly this error ? anywhere know ? –  May 04 '15 at 16:42
  • 2
    I wish I could tell you exactly what it is, but the error persists in Android Studio 1.2. Creating a new project with a blank activity generates the same error as above. It may resolve itself as you begin to actually create a layout, but changing the theme seems like the best way to go to me. Others may think changing the build API is correct, but that's not the solution I prefer. – Zeus56 May 06 '15 at 15:48
  • I faced a similar issue but when I removed the deprecated ActionBarActivity and instead used AppCompatActivity, then things worked out without any more changes. The [page](http://developer.android.com/tools/support-library/index.html) refers to the changes for v7 appcompat library. – Neeraj May 19 '15 at 02:17
  • I am new to working with Android Studio. How do you change the project theme after you have already created the project? – DaveTheMinion Jun 14 '15 at 00:31
62

Possible solutions that worked for me:

1 -> Add the word Base. to the beginning of the theme name so that it reads "Base.Theme.AppCompat.Light.DarkActionBar"

i.e., Change AppTheme parent in res/values/styles.xml to resolve this problem. Replace

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

with

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

OR

2- > Downgrade API level from 22 to 21 in preview pane as suggested by @david.schreiber

Amrit Pal Singh
  • 7,116
  • 7
  • 40
  • 50
29

I changed the AppTheme above the graphical preview to Base.Theme.AppCompat and it disappeared for me. It worked on both 19 and 22 API :) ! Good Luck to all of you!

see what i did
click for larger image

Michael Myers
  • 188,989
  • 46
  • 291
  • 292
Valentin Filyov
  • 632
  • 7
  • 16
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – lshettyl Apr 17 '15 at 20:53
  • 2
    @LShetty: if i.stack.imgur.com goes down, we're all in a heap of trouble. – Michael Myers Apr 17 '15 at 21:18
  • But what if you have your own app theme (which itself has `Base.Theme.AppCompat...` as a parent)? Wouldn't you want to preview how the layout looks with your theme? – user1987392 May 12 '15 at 09:14
  • I've been staring at error screens the for months before I found this. Thanks! – 1mike12 Mar 11 '16 at 19:45
8

I changed my app theme from "Theme.AppCompat.Light.DarkActionBar" to "Base.Theme.AppCompat.Light.DarkActionBar"

KiDa
  • 233
  • 1
  • 3
  • 10
2

I encountered this problem just now in Android Studio 1.2.1.0 with API 22 (Android 5.1.1) selected without changing the theme or API as suggested by others on this thread.

When I updated to the most recent version of Android Studio available via the regular update check, it works fine now. This shouldn't be a problem in the new version Android Studio 1.2.1.1

George Pantazes
  • 1,039
  • 3
  • 12
  • 26
1

Change android version from 22 to 21, problem solved, it's the little android icon at top right corner,

Flexo
  • 87,323
  • 22
  • 191
  • 272
hank
  • 21
  • 1
1

Adding to david.schreiber's answer, if you keep your preview in a tight window you may wanna stretch it to access that Android icon.

enter image description here

enter image description here

Teo Inke
  • 5,928
  • 4
  • 38
  • 37
1

I'm using Android Studio 1.2 as stable version and I have the same problem.

For me the solution was to use the Canary Channel and update Android Studio to 1.3.

Now I have this version and it works perfect but this is not and stable version

enter image description here

My build.grade is this

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "com.androidtest.materialdesign"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
}
Jorge Casariego
  • 21,948
  • 6
  • 90
  • 97
0

Changing app theme to Base.Theme.App.Compat worked for me.

Kajal
  • 206
  • 2
  • 8
0
  • Clean project
  • Rebuild project
  • Sync Gradle
TitaniuM
  • 321
  • 1
  • 10
  • 19