Android studio 不渲染布局预览 [英] Android studio not rendering layout preview

查看:34
本文介绍了Android studio 不渲染布局预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 Android Studio 0.8.6 开发应用程序,并且在使用 API21 时遇到布局预览问题.我收到以下错误:

<块引用>

渲染问题:无法实例化以下类:- android.support.v7.widget.Toolbar

我下载并安装了最新的 SDK Build 工具 (21.0.2) 以及完整的 API21.我的 targetSDKVersion 在 gradle 文件中设置为 21.如果我将预览更改为使用 API20 渲染,一切似乎都很好.下面提供了例外详情.

谢谢!

<块引用>

异常详情 java.lang.ClassNotFoundException:android.support.v4.content.ContextCompatApi21 在com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:148)在 java.lang.ClassLoader.loadClass(ClassLoader.java:424) 在java.lang.ClassLoader.loadClass(ClassLoader.java:357) 在android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:319)在android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:133)在android.support.v7.internal.widget.TintTypedArray.getDrawable(TintTypedArray.java:62)在 android.support.v7.widget.Toolbar.(Toolbar.java:248) 在android.support.v7.widget.Toolbar.(Toolbar.java:190) 在java.lang.reflect.Constructor.newInstance(Constructor.java:408) 在android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)在android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)在 android.view.LayoutInflater.rInflate(LayoutInflater.java:782)在 android.view.LayoutInflater.inflate(LayoutInflater.java:504) 在android.view.LayoutInflater.inflate(LayoutInflater.java:385)

解决方案

Android Studio 的最新版本是 0.8.14,这修复了 API21 的许多问题.请注意,根据 Android Studio 0.8.12 公告(在无补丁"下):><块引用>

我们发现并修复了修补机制中的几个重要错误.这些错误之一意味着升级到新版本,同时导致功能相同的安装,也会导致二进制内容略有不同(例如,.jar 文件中的某些时间戳会有所不同).这意味着实际的二进制签名将不匹配,这会破坏例如应用程序签名检查.

我们现在已经发现并修复了该错误,但是由于给定的先前版本有许多不同的二进制变体,我们无法创建单个补丁来更新到新版本.因此,对于此版本,我们需要完整下载 IDE.从这个版本开始,我们应该能够在保留应用程序签名的同时准确安装更新.

因此您需要手动安装最新版本.>

I've been using Android Studio 0.8.6 to develop apps and am having problems with the layout preview when using API21. I get the following error:

Rendering Problems: The following classes could not be instantiated: - android.support.v7.widget.Toolbar

I have SDK Build tools up-to-date (21.0.2) as well as the full API21 downloaded and installed. My targetSDKVersion is set to 21 on the gradle file. If I change the preview to render with API20, everything seems fine. Exception details are provided below.

Thanks!

Exception Details java.lang.ClassNotFoundException: android.support.v4.content.ContextCompatApi21   at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:148)   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)   at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:319)   at android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:133)   at android.support.v7.internal.widget.TintTypedArray.getDrawable(TintTypedArray.java:62)   at android.support.v7.widget.Toolbar.(Toolbar.java:248)   at android.support.v7.widget.Toolbar.(Toolbar.java:190)   at java.lang.reflect.Constructor.newInstance(Constructor.java:408)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)   at android.view.LayoutInflater.inflate(LayoutInflater.java:504)   at android.view.LayoutInflater.inflate(LayoutInflater.java:385)

解决方案

The most recent version of Android Studio is 0.8.14 and this fixes a number of issues with API21. Note that as per the Android Studio 0.8.12 announcement (under 'No patches'):

We've found and fixed several significant bugs in the patching mechanism. One of these bugs meant that upgrading to a new version, while resulting in a functionally identical installation, would also result in slightly different binary contents (for example, some timestamps inside .jar files would differ). This meant that the actual binary signatures would not match, which broke for example the application signature checks.

We have now found and fixed that bug, but because there are many different binary variations of a given previous version, we cannot create a single patch to update to the new version. Therefore, for this version we will require a full download of the IDE. From this version forward we should be able to accurately install updates while preserving the application signatures.

So you'll need to manually install the latest build.

这篇关于Android studio 不渲染布局预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆