[英]Android Studio not rendering preview
我知道这是常见问题,但是我已经尝试过
Base.
在styles.xml
,所有这些都不能解决问题。 似乎这一次问题出在其他地方,因为所有元素都是最新的。
我在Android Studio的预览屏幕中遇到以下错误:
The following classes could not be found:
- android.support.v7.widget.Toolbar
Gradle版本是1.2.3。 我刚刚安装了Android Studio + SDK。
建立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()
}
}
和
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'
...
}
您正在使用支持库中的工具栏,但似乎没有将其作为依赖项包括在内。 您应该在build.gradle文件中添加以下内容:
dependencies {
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.