4

I just updated my Android Studio to latest 3.0 and then the Layout Preview is not working anymore. I have tried open up different projects and they all have the same render issues. As I checked, I don't see any compile errors or gradle issues. So far, I tried

  • Build Project
  • Refresh Layout
  • Clean Project
  • Invalid Caches / Restart

The following attached screenshot shows that some classes cannot be initiated but I dont get why and how to fix them. Thank you very much. Any hints could help.

layout redering

Updates: It seems there is a duplicate case at Render error in Android Studio 3.0 Layout Editor but mine problem is slightly different. The solution for above linked issue is to modify the theme to a more specific one by clarifying parent theme under Base.Theme.AppCompat.Light.DarkActionBar. However, I don't even have an ActionBar so I am looking for a solution for Theme.AppCompat.NoActionBar.

Before updating to 3.0, everything is fine. I wonder if I need to change deployment SDK/Version.

x_xiao2_bnu
  • 191
  • 1
  • 2
  • 8
  • 5
    Possible duplicate of [Render error in Android Studio 3.0 Layout Editor](https://stackoverflow.com/questions/44223687/render-error-in-android-studio-3-0-layout-editor) – Joseph Mathew Oct 29 '17 at 04:52

6 Answers6

12

OK, I tried to explore every possible solution but no work. I finally figured it out by changing the deployment SDK/Version. I changed all to 26 and it fixed my problems. As I tested version lower and higher, it seems only ver 26 can work.

android {
 compileSdkVersion 26
 buildToolsVersion '26.0.2'
...
 defaultConfig {
  targetSdkVersion 26
...
 }
}
...
dependencies {
  compile 'com.android.support:appcompat-v7:26.0.0'
  compile 'com.android.support:design:26.0.0'
  compile 'com.android.support:support-v13:26.0.0'
  compile 'com.android.support:support-v4:26.0.0'
  compile 'com.android.support:palette-v7:26.0.0'
...
}

So if the solution at Render error in Android Studio 3.0 Layout Editor does not work for you. You can try 26. Let me know.

x_xiao2_bnu
  • 191
  • 1
  • 2
  • 8
  • Thanks for sharing. I've changed to 26 and the preview appeared again and then changed back to 27 and it is still there. Actually, I only changed to compileSdkVersion temporarily to 26. But still, that somehow solved it. – Thor_Bux Mar 06 '18 at 08:23
2

This is a serious bug in Android Studio 3.0, when using support libraries that are not version 26. As of November 2017, it's not yet fixed and it has been reported several times:

In Stackoverflow:

In Google Issue tracker:

Update April 2018: The minimum support library version is 25.4.0, for Android Studio 3.0 and 3.1. More info in the Google Issue Tracker links.

Mr-IDE
  • 7,051
  • 1
  • 53
  • 59
1

JUST CHANGE alpha3 to alpha1 in gradle module app implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

SANDY G
  • 11
  • 1
0

Click on Design tab >> Top corner layout option (Design, Blueprint) >> Select Force Refresh Layout.

Dharmendra
  • 189
  • 3
  • 11
0

You need to install SDK platforms depends on which compat library you are using.

For example:

If you are using compile 'com.android.support:appcompat-v7:25.0.0'. Make sure SDk platforms API 25 is downloaded.

To check downloaded SDK platforms, goto

Tools-> Sdk Manager ->Sdk Platforms.

then download the required platforms depends on the library you are using.

Restart the Android studio to effect the changes.

Anil Raavi
  • 131
  • 1
  • 10
0

I had that same problem. After searching, I found that there was a problem with API 28, which was the one I had at that time. What I did was download the 26 and I could fix it. Go to Tools / SDK Manager / SDK Platforms / Download API 26 and delete another one we have.

Martin Olariaga
  • 379
  • 4
  • 4
  • Another thing, when I reopened it had by default the API 28 of the editor, it is simply necessary to change it to 26, and if we have created the project with API 26, we will have no problem. – Martin Olariaga Jun 15 '18 at 14:39