【问题标题】:Android Toolbar class not found未找到 Android 工具栏类
【发布时间】:2015-05-04 17:43:28
【问题描述】:

我今天将 Android Studio 升级到 1.2 并收到此错误。

找不到以下类:android.support.v7.widget.Toolbar (Fix Build Path, Create Class)

我的 build.gradle 包含以下依赖项

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

有人可以帮我解决这个问题吗?

【问题讨论】:

  • 试用工具 > Android > 将项目与 Gradle 文件同步。
  • @CommonsWare 问题仍然存在。
  • 问题是来自代码还是来自 xml 样式?
  • 嗯,我找不到帮助我参考的帖子,但为我解决的问题是在 / 下更改
  • 我相信是 AS 1.2 known issue!

标签: android android-studio android-xml android-toolbar


【解决方案1】:

这个问题可以(偶尔)通过使缓存失效来解决

File > Invalidate Caches / Restart > Invalidate and Restart

见下文:

【讨论】:

    【解决方案2】:

    Android Known Issue: 这是错误170841,将在版本 1.2.3 中修复 Android Gradle 插件。

    解决方法一:先手动构建项目,然后手动同步 项目(使用工具栏中的与 Gradle 文件同步,或从 工具 > Android 菜单),然后最后按上方工具栏中的刷新 布局编辑器。解决方法 2:将 Android Gradle 插件从 现在是 1.2.x 到 1.1.3。 1.2.3 发布后,您可以切换回 1.2.x 版本。

    【讨论】:

      【解决方案3】:

      您的项目文件夹中有android-support-v7-appcompat.jar/lib/libs 等)吗?删除它!然后尝试删除它并制作Run - Clear project

      【讨论】:

        猜你喜欢
        • 2019-02-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-17
        相关资源
        最近更新 更多