194

I'm using Android Studio 0.2.3 and when opened an activity layout normally, the preview should appear on the right side, so that I can switch between Text and Design mode, which should again show the preview of the layout.

But no preview is shown not on the right side neither when I'm in text mode nor in the design mode. I just get the error rendering problems...

When I compile everything and install the app on my device, it works without any errors. For developing and experimenting with the layout, it would still be nice if I could get the preview to work.

I have also tried to switch between different devices in the studio, but no success.

Does anyone know how solve this?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
wasp256
  • 5,943
  • 12
  • 72
  • 119
  • 1
    Did you ever find a solution to this. I am having the same problem with 0.2.6 and 0.2.7. No errors and it works fine on the device but I can't get the preview working. – Tim Sep 06 '13 at 05:18
  • No unfortunately I didn't when I restart the studio the preview is working again for some time but when I start to add/modify many components I get the error again, I guess that my notebook may be to slow (it's pretty old ;)) to do the rendering thing in time or something like that – wasp256 Sep 06 '13 at 06:19
  • Sadly I have the error at the moment and it doesn't work at all, no matter if I restart. If I force an error in the layout it lists it, otherwise when it's correct it just says rendering problems. My pc isn't all that old or slow. I can manually edit the file and test it on the device but it's frustrating not having the preview – Tim Sep 07 '13 at 23:55
  • I've installed studio version 0.2.7 and java version 7...The problem you describe seems to be exactly the same I have but unfortunatelly I've no idea what the problem might be – wasp256 Sep 08 '13 at 11:38
  • 1
    possible duplicate of [Rendering problems for Android Studio](http://stackoverflow.com/questions/30691904/rendering-problems-for-android-studio) – H. Pauwelyn Aug 16 '15 at 11:56
  • In my case I commented out a `TextClock` and then un commented it again, and the layout showed up. – Reejesh PK Aug 20 '20 at 05:46

17 Answers17

531

Change your android version on your designer preview into your current version depend on your Manifest. rendering problem caused your designer preview used higher API level than your current android API level.

Adjust with your current API Level

Adjust with your current API Level. If the API level isn't in the list, you'll need to install it via the SDK Manager.

Adiyat Mubarak
  • 10,279
  • 4
  • 34
  • 50
  • what null?? could you give more explain? – Adiyat Mubarak Aug 15 '14 at 18:29
  • 1
    when you preview your layout, there is a small android in the right corner in which we specify the API level, Well it supposed to be 19 , But mine was showing . But I resolved that I updated the gradle to 2.0 and changed the gradle home rebuild the project and restart the studio and now its showing 19...so All set here – Nipun David Aug 16 '14 at 12:20
  • @Keda87 is your project building properly? I was also getting `` in Android version dropdown but got proper SDK versions after project was successfully built. – TheVillageIdiot Dec 06 '14 at 11:09
  • @TheVillageIdiot Yes, but honestly I never get that kind of error. have you tried Nipun David solution?? I think you had simillar problem with him. – Adiyat Mubarak Dec 08 '14 at 10:49
  • @Keda87 No, I did not get any version in drop-down until I was able to compile project successfully. – TheVillageIdiot Dec 09 '14 at 09:57
  • In my case, I have had to move the API level around a bit. It finally worked on API 16 – Katedral Pillon Apr 08 '15 at 21:40
  • hay, my preview is not refreshing thats my case, it show the preview but after i do some change to xml code it didnt refresh and apply the change, can somebody help me with that? – Ashana.Jackol Aug 13 '16 at 06:17
25

In new update android studio 2.2 facing rendering issue then follow this steps.

I fixed it - in styles.xml file I changed

"Theme.AppCompat.Light.DarkActionBar"

to

"Base.Theme.AppCompat.Light.DarkActionBar"

It's some kind of hack I came across a long time ago to solve similar rendering problems in previous Android Studio versions.

Arpit Patel
  • 7,212
  • 5
  • 56
  • 67
18
  1. Open AndroidManifest.xml
  2. Change:

    android:theme="@style/AppTheme"

    to something like:

    android:theme="@style/Theme.AppCompat.Light"
  3. Hit "refresh" button in the "Previev" tab.
H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
Andrew
  • 36,676
  • 11
  • 141
  • 113
14

I was able to fix this in Android Studio 0.2.0 by changing API from API 18: Android 4.3 to API 17: Android 4.2.2

This is under the Android icon menu in the top right of the design window.

This was a solution from http://www.hankcs.com/program/mobiledev/idea-this-version-of-the-rendering-library-is-more-recent-than-your-version-of-intellij-idea-please-update-intellij-idea.html.This required a Google translation into English since it was in another language.

Hope it helps.

Eames
  • 321
  • 2
  • 19
user2798692
  • 163
  • 8
11

In the Latest Android Studio 3.1.3, Dependency:

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'

or

Even in latest by 27th of Aug 18 ie

implementation 'com.android.support:appcompat-v7:28.0.0-rc01' facing similar issue

Change it to

    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1

This will solve your problem of Preview.

UPDATE

Still, in beta01 there is a preview problem for latest appcompact v7 library make the above change as changing it to alpha01 for solving rendering problem

11

When I set that android:autofillHints="" /> in .xml file, I met the issue, Android Studio rendering problems, so I set that android:autofillHints="testHint" />, this issue is gone.

Jin
  • 156
  • 1
  • 4
  • Solved my problem, helps with latest android studio 4.2.1 as well. – Piepypye May 14 '21 at 22:10
  • Spot on. I had `java.lang.StringIndexOutOfBoundsException: String index out of range: -1`. I have no idea how did you end up finding this attribute as an error trace gives no clues. Thanks a lot. – ruX Aug 30 '21 at 14:43
6

I have solved the Problem by changing style.xml

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

this was an awesom solution.

Sajidkhan
  • 608
  • 7
  • 16
  • Ive been looking a solution for this issue for like a month. This resolved it! Thank u!!! –  Apr 20 '18 at 03:38
2

it still happens in Android Studio 1.5.1. on Ubuntu and you can solve it simply changing a setting from Gradle:

1) on app/build.gradle dependencies change from:

compile 'com.android.support:design:23.2.0'

to:

compile 'com.android.support:design:23.1.0'

2) rebuild project

3) refresh view

Best regards,

/Angel

Angel
  • 940
  • 1
  • 9
  • 21
1

I had the same problem, current update, but rendering failed because I need to update.

Try changing the update version you are on. The default is Stable, but there are 3 more options, Canary being the newest and potentially least stable. I chose to check for updates from the Dev Channel, which is a little more stable than Canary build. It fixed the problem and seems to work fine.

To change the version, Check for Updates, then click the Updates link on the popup that says you already have the latest version.

John
  • 1,407
  • 7
  • 26
  • 51
1

In build.gradle below dependencies add:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == "com.android.support") {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "27.+"
            }
        }
    }
}

This worked for me, I found it on stack, addressed as the "Theme Error solution": Theme Error - how to fix?

quant
  • 493
  • 9
  • 21
0

Rendering didn't work for me too. I had <null> value on the right side of the android icon. I ran

sudo apt-get install gradle

I restarted Android studio then and <null> value changed to 23.

Voila, it renders now! :)

enter image description here

MartyIX
  • 27,828
  • 29
  • 136
  • 207
0

Just download minimum prefered SDK from SDK Manager, then build. Works for me.

Ryde
  • 654
  • 8
  • 23
0

Make sure your designer version and targetSdkVersion both is same. Example : If your targetSdkVersion is 22 then change your designer version also 22, so this problem do not occur.

patel135
  • 927
  • 13
  • 19
0

Best Solution is go to File -> Sync Project With Gradle Files

I hope this helped

Abdul Wahab
  • 99
  • 1
  • 2
  • 11
0

All you had to do is go to styles.xml file and replace your parent theme from

 Theme.AppCompat.Light.DarkActionBar 
to 
 Base.Theme.AppCompat.Light.DarkActionBar
Maryam Azhdari
  • 1,161
  • 11
  • 8
0

Open your activity_main.xml . Switch to Design view if you are in text view. Look for the android version,with the android robo icon. Change the android version. Problem solved.

Pravin Ghorle
  • 606
  • 7
  • 7
0

this issue is probably derived from the connection of the laptop to software products like AnyConnect. Killing the remote connection works for me.