Android studio does not create layout preview

I use Android Studio 0.8.6 for application development, and I am having problems previewing the layout when using API21. I get the following error:

Rendering Issues: The following classes could not be created: - android.support.v7.widget.Toolbar

I have built-in SDK development tools (21.0.2), and the full API21 is downloaded and installed. My targetSDKVersion is set to 21 in the gradle file. If I changed the preview for rendering with API20, everything seems fine. Exception details are provided below.

Thank!

Java.lang.ClassNotFoundException exception information: android.support.v4.content.ContextCompatApi21 at com.intellij.util.lang.UrlClassLoader.findClass (UrlClassLoader.java:148) in java.lang.ClassLoader.loadClass (ClassLoader.java: 424) in java.lang.ClassLoader.loadClass (ClassLoader.javahaps57) in android.support.v4.content.ContextCompat.getDrawable (ContextCompat.javahaps19) in android.support.v7.internal.widget.TintManager.getDrawable (TintManager.java:133) in android.support.v7.internal.widget.TintTypedArray.getDrawable (TintTypedArray.java:62) in the android.support.v7.widget.Toolbar file. (Toolbar.java:248) in android.support.v7.widget.Toolbar. (Toolbar.java:190) at java.lang.reflect.Constructor.newInstance (Constructor.java:408) in android.view.LayoutInflater.rInflate_Original (LayoutInflater.java:806) in android.view.LayoutInflater_Delegate.rInflate_ Layout. java: 64) on android.view.LayoutInflater.rInflate (LayoutInflater.java:782) on android.view.LayoutInflater.inflate (LayoutInflater.java:504) in android.view.LayoutInflater.inflate (LayoutInflater.javahaps85)

+19
android android-5.0-lollipop android-studio
Oct 27 '14 at 19:00
source share
8 answers

The latest version of Android Studio is 0.8.14 , and this fixes a number of problems with API21. Please note that according to the announcement of Android Studio 0.8.12 (in the "No Patches" section):

We discovered and corrected several significant errors in the correction mechanism. One of these errors meant that upgrading to a new version, resulting in a functionally identical installation, would also lead to slightly different binary contents (for example, some timestamps inside .jar files will be different). This meant that the actual binary signatures did not match, which violated, for example, the signature verification of the application.

Now we have discovered and fixed this error, but since there are many different binary options for this previous version, we cannot create one patch for updating to a new version. Therefore, for this version we need a full download of the IDE. Starting with this version, we should be able to accurately install updates, while maintaining application signatures.

So, you need to manually install the latest version .

+6
Oct 27 '14 at 19:26
source share

This problem returned to me in Android Studio 1.2.

This is what I did and worked.

  • Clear project
  • Restructuring project
  • Gradle Sync
  • Click update layout preview button
+43
May 01 '15 at
source share

Try to opt out of the "Automatically choose the best" option in the "View" area and choose an older API when viewing the XML layout. This is located in the menu bar, where you select the device and theme that you want to use for preview, and all this on the right.

+7
Oct 27 '14 at 19:26
source share

This is a known issue , see below.

False render exception

Specific rendering error message: The following classes could not be found:

android.support.v7.internal.app.WindowDecorActionBar 

Despite the error message, the layout preview is correct and the message can be safely ignored . The problem has already been fixed in preview 2.0. More on bug 192102 . (The link to the problem is no longer valid).

+3
Dec 6 '15 at 21:16
source share

Change the parent style to Theme.AppCompat.Light.NoActionBar instead of Theme.AppCompat.Light.DarkActionBar in styles.xml ......... it worked for me.

+3
Oct 16 '16 at 6:56
source share

I ran into the same issue in android 2.2 studio

This is what I did and nothing

-Clean Project

-Rebuild project

-Sync Gradle

The only thing that actually worked for me was rebooting Android studio (close and open again)

0
Jun 29 '16 at 15:29
source share
  • Clear project
  • Restructuring project
  • Gradle Sync
  • Click update layout preview button

The Refresh Preview Layout button is located above the preview of the Android phone, and one with the blue circular arrows, to the right - magnifying glass zoom buttons.

Note: this solution does nothing until the update layout button is pressed in the last step and then it works. This posed a problem for me. I am using Android Studio v2.1.2.

Hurrah!

0
Aug 09 '16 at 12:36
source share
  • Clear project
  • Restructuring project
  • Gradle Sync
  • Preview Press Layout Button

or

in your XML file, right-click and mark it as XML.

which should work.

0
Jan 03 '17 at 1:41 on
source share



All Articles