Android的工作室未呈现preVIEW [英] Android Studio not rendering preview
本文介绍了Android的工作室未呈现preVIEW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这是常见的问题,但我已经试过
- 清洗和重建项目
- 无效并重新启动
- 设置内部版本到其他的22
- 更改摇篮的版本
- 添加
基础。
在styles.xml
而没有这不会解决问题。
它似乎此时的问题是别的地方,因为所有元件均达到最新
我在Android Studio中的preVIEW屏幕得到以下错误
以下类找不到:
- android.support.v7.widget.Toolbar
摇篮版本为1.2.3。我刚刚安装的Android工作室+ SDK。
的gradle构建:
//顶级构建文件,您可以添加常用的配置选项,所有分项目/模块。buildscript {
库{
jcenter()
}
依赖{
类路径'com.android.tools.build:gradle:1.2.3 //注意:不要在这里把你的应用程序依赖关系;他们属于
//在单个模块的build.gradle文件
}
}allprojects {
库{
jcenter()
}
}
和
应用插件:'com.android.application 安卓{
compileSdkVersion 21
buildToolsVersion '22 .0.1 defaultConfig {
的applicationIDcom.sth.sth
15的minSdkVersion
targetSdkVersion 22
版本code 1
的versionName1.0
}
buildTypes {
发布 {
minifyEnabled假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
}
}
依赖{
编译文件树(包括:['的* .jar'],DIR:库)
编译com.android.support:appcompat-v7:22.1.1
编译com.android.support:cardview-v7:21.0.3
...
}
解决方案
您正在使用从支持库工具栏,但似乎你不包括它作为一个依赖。你应该添加这样的事情在你的build.gradle文件:
{相关性
编译com.android.support:support-v4:22.1.1
编译com.android.support:appcompat-v7:22.1.1
}
I know this is common question, but I have tried
- Cleaning and Rebuilding Project
- Invalidating and restarting
- Setting build version to other that 22
- Changing version of Gradle
- adding
Base.
instyles.xml
and none of this doesn't fix the issue.
It's seems that this time the problem is somewhere else, because all elements are up-to-date.
I am getting following error at the preview screen in Android Studio :
The following classes could not be found:
- android.support.v7.widget.Toolbar
Gradle version is 1.2.3. I have just installed Android Studio + SDK.
Build gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
and
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.sth.sth"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:cardview-v7:21.0.3'
...
}
解决方案
You're using the toolbar from the support library, but it seems that you aren't including it as a dependency. You should add something like this in your build.gradle file:
dependencies {
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'
}
这篇关于Android的工作室未呈现preVIEW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文