简体   繁体   English

Android Studio 预览渲染

[英]Android Studio Preview Rendering

I am getting the following error in Android Studio layout preview :我在 Android Studio 布局预览中收到以下错误:

Rendering Problems The following classes could not be found:android.support.v7.widget.Toolbar (Fix Build Path, Create Class)
Tip: Try to build the project."

I am using Android Studio 1.3 Preview 3 release.我正在使用Android Studio 1.3 Preview 3 版本。 with buildToolsVersion "21.1.2", com.android.tools.build:gradle:1.3.0-beta1", compileSdkVersion 21.使用 buildToolsVersion "21.1.2", com.android.tools.build:gradle:1.3.0-beta1", compileSdkVersion 21。

The App builds successfully and runs perfectly on my phone though.该应用程序成功构建并在我的手机上完美运行。 How can solve this issue?如何解决这个问题? Note that the problem is NOT of instantiation as pointed by the possible duplicate.请注意,问题不在于可能的重复所指出的实例化。 The issue is only in rendering, the App builds and runs without issues.问题仅在于渲染,应用程序构建和运行没有问题。

Go to styles.xml, you can found there something like转到styles.xml,您可以在那里找到类似的东西

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.Darkactionbar">

Add " Base. " before " Theme ", to在“主题”之前添加“基础”,以

<style name="AppBaseTheme" parent="Base.Theme.AppCompat.Light.Darkactionbar">

it's something like a bug in Android Studio这有点像 Android Studio 中的错误

Add dependency for the AppCompat library in your app's build.gradle file:在应用的build.gradle文件中为 AppCompat 库添加依赖build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
}

Note that the version number 22.0.0 depends on the latest support library found in your android sdk for the appCompat library请注意,版本号 22.0.0 取决于在您的 android sdk 中为 appCompat 库找到的最新支持库

I had a similar issue.我有一个类似的问题。 What worked for me was to change the API to a lower version, I am using the 21 for exemple.对我有用的是将 API 更改为较低版本,例如我使用的是 21。
On the layout preview screen, there is a tinny Bugdroid, click on him then choise your API version.在布局预览屏幕上,有一个小巧的 Bugdroid,点击他然后选择你的 API 版本。 you might also want to unclick the Automically Pick Best option.您可能还想取消单击自动选择最佳选项。
Hope it helped !希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM