Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 3.0 Layout Preview render issues

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.

like image 750
x_xiao2_bnu Avatar asked Dec 06 '22 13:12

x_xiao2_bnu


2 Answers

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.

like image 165
x_xiao2_bnu Avatar answered Dec 08 '22 02:12

x_xiao2_bnu


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:

  • Why preview not showing for many layout since update to android studio 3.0?
  • Render error in Android Studio 3.0 Layout Editor
  • Failed to load AppCompat ActionBar with unknown error in android studio

In Google Issue tracker:

  • https://issuetracker.google.com/issues/68353097 - Cannot display preview of layout after update to Android Studio 3.0
  • https://issuetracker.google.com/issues/68498497 - Android Studio 3.0 Preview ScrollView
  • https://issuetracker.google.com/issues/68423477 - Rendering issue with layout preview after updating to Android Studio 3.0
  • https://issuetracker.google.com/issues/68288395 - After upgrade android studio as 3.0, layout preview is not showing with error
  • https://issuetracker.google.com/issues/65858429 - Preview is not working in Android Studio 3.0-Beta6
  • https://issuetracker.google.com/issues/64028640 - Rendering problem still exists on AS 3.0 canary 8 "Failed to load AppCompat ActionBar with unknown error." and Failed to instantiate one of more classes on android.support:appcompat-v7:26.0.0-beta2
  • https://issuetracker.google.com/issues/63786429 - Layout Editor Not Displaying Preview in Android Studio 3.0 Preview 7

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.

like image 37
Mr-IDE Avatar answered Dec 08 '22 03:12

Mr-IDE