【问题标题】:Error on Adding ActionBarSherlock in Intellij-Idea 13在 Intellij-Idea 13 中添加 ActionBarSherlock 时出错
【发布时间】:2014-05-26 14:45:52
【问题描述】:

通过所有教程在项目中添加库后,我在 style.xml 中出现错误

Error: No resources found that matches the given name: attr 'switchStyle'
Error: No resources found that matches the given name: attr 'textAppearance'

在 Eclipse 中我可以选择“clean project”,这个问题会消失,直到下次更改 style.xml

<style name="AppTheme" parent="Theme.Sherlock.Light">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="switchStyle">@style/switch_light</item>
        <item name="textAppearance">@style/TextAppearance</item>
        <item name="android:actionBarStyle"  tools:ignore="NewApi">@style/Widget.Styled.ActionBar</item>
</style>

我的步骤:

  • 在 Eclipse 中创建的项目现在导入到 IntelliJ IDEA
  • 项目和 ActionBar SDK 设置 - Google Android 4.4.2
  • 清单项目设置:minSDK - 10;目标 SDK - 19
  • 将模块添加到项目设置(不是 jar - 通过导入模块的所有 ActionBar 项目 -> 选择 ActionBar 文件夹 -> 从现有源创建模块或从外部模块 Eclipse 导入)
  • 将模块依赖添加到 support-v4
  • 将 ActionBar 模块添加到 Project 模块的依赖项中
  • 在 Facets ActionBar 模块中是库
  • 从导入的 ActionBar 模块测试文件夹中删除
  • 重建项目 - 错误
  • 制作项目 - 错误。

附言。项目很旧,在没有 Gradle 的 Eclipse 中创建。

【问题讨论】:

    标签: android intellij-idea actionbarsherlock


    【解决方案1】:

    1) 尝试用 AAR 替换模块依赖。只需将此添加到您的build.gradle

    dependencies {
        compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    }
    

    2) 检查您的主题。您需要为 ActionBar 创建一个自定义样式,然后应用它。以下是正确方法的示例:

    <style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
        <item name="actionBarStyle">@style/Widget.Custom.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.Custom.ActionBar</item>
    </style>
    
    <style name="Widget.Custom.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
        <item name="background">@drawable/bg_striped</item>
        <item name="android:background">@drawable/bg_striped</item>
    
        <item name="backgroundSplit">@drawable/bg_striped_split</item>
        <item name="android:backgroundSplit">@drawable/bg_striped_split</item>
    </style>
    

    【讨论】:

    • 这是在没有 Gradle 的 Eclipse 中创建的旧项目。现在我正在尝试在 Intellij 中导入项目。但是团队的其他成员仍然在 Eclipse 中工作。
    • @DreamVan 你为什么不用Android Studio?
    • Android Studio 和 Intellij 一样,不是吗?团队不想从 Eclipse 更改 IDE
    • 是的,基本上是 Intellij。但是Android Studio使用gradle作为构建工具,这是一个巨大的进步
    【解决方案2】:

    在我的情况下,问题在于 ActionBarSherlock 的第三方模块的依赖关系。所有的痕迹是: - 我的项目依赖于 ActionBarSherlock 和其他也依赖于 ABS 的模块 - 项目引用第三部分模块中ActionBar BUT的样式

    原来整个事情都在我的疏忽中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-31
      • 1970-01-01
      • 1970-01-01
      • 2018-09-12
      • 2014-01-30
      相关资源
      最近更新 更多