【问题标题】:Android Studio can't find compatibility library stylesAndroid Studio 找不到兼容库样式
【发布时间】:2014-02-14 00:46:37
【问题描述】:

我依靠兼容性库在旧版本的 Android 上使用操作栏。我已将其添加到我的build.gradle 文件中,如下所示:

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:support-v4:+'
}

还有一个styles.xml 文件的示例:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Base theme -->
    <style name="AppName" parent="@style/Theme.AppCompat.Light"></style>
</resources>

项目在 Android Studio 0.4.4 中通过命令行和 IDE 成功构建。但是,在编辑器中打开文件时出现以下错误:

我尝试过使缓存无效、清理项目、与 Gradle 同步并在删除 IntelliJ 文件后重新导入项目,但没有任何变化。我在build.gradle 文件中也遇到这样的错误:

但我不知道这是否与这个特定问题有关。如何让 Android Studio 找到兼容库资源?

【问题讨论】:

  • 这是0.4.2的问题,0.4.4看到这样的事情我很惊讶,看看这个问题stackoverflow.com/questions/21316055/…
  • @pyus13 奇怪的是Android Studio可以找到类,只是找不到资源。

标签: android-studio


【解决方案1】:

这似乎是Android Studio中的一个错误,我在这里报告了这个错误

https://code.google.com/p/android/issues/detail?id=65979&thanks=65979&ts=1392399233

点击此链接获取更新。

但是在你的问题中我想知道的一件事是@styleTheme.AppCompat.Light之前@style仅用于引用您自己的样式。对于appcompat样式我直接使用Theme.AppCompat.Light like

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
</style>

但在我的情况下,根据您的问题也显示错误。

对于 build.gradle 文件:

截至目前,gradle 文件编辑器为 android 标记内的所有内容显示 "Cannot find symbols"。不是问题。

【讨论】:

  • 是的,我后来添加了@style 试图修复它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-21
  • 1970-01-01
  • 1970-01-01
  • 2016-07-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多