Android Studio无法渲染预览

时间:2015-05-26 13:47:00

标签: android android-studio gradle

我知道这是一个常见的问题,但我已经尝试了

  • 清洁和重建项目
  • 无效并重新启动
  • 将构建版本设置为其他22
  • 更改Gradle版本
  • right click existing task -> new -> subtask中添加Base. 并且这些都不能解决问题。

似乎这次问题出在其他地方,因为所有元素都是最新的。

我在Android Studio的预览屏幕上收到以下错误:

styles.xml

Gradle版本是1.2.3。我刚刚安装了Android Studio + SDK。

构建gradle:

The following classes could not be found:
- android.support.v7.widget.Toolbar

// 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()
    }
}

1 个答案:

答案 0 :(得分:0)

您正在使用支持库中的工具栏,但似乎您并未将其作为依赖项包含在内。你应该在build.gradle文件中添加这样的东西:

dependencies {
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
}
相关问题