【问题标题】:Android Studio Appcompat conflict with ActionBarSherlock [duplicate]Android Studio Appcompat 与 ActionBarSherlock 冲突 [重复]
【发布时间】:2015-12-04 15:06:34
【问题描述】:

我尝试将 eclipse 项目导入到 android studio 并得到这个错误

Error:(1) Attribute "titleTextStyle" has already been defined
Error:(1) Attribute "subtitleTextStyle" has already been defined
Error:(1) Attribute "divider" has already been defined
Error:(1) Attribute "background" has already been defined
Error:(1) Attribute "backgroundSplit" has already been defined
Error:(1) Attribute "navigationMode" has already been defined
Error:(1) Attribute "displayOptions" has already been defined
Error:(1) Attribute "title" has already been defined
Error:(1) Attribute "subtitle" has already been defined
Error:(1) Attribute "icon" has already been defined

我发现 appcombat 与 actionbarsherlock 冲突。我尝试从 abs 迁移到 appcombat 但是。似乎我得到的项目是用 actionbarsherlock 硬编码的。所以这对我来说是不可能的。我决定排除 appcombat,这样 actionbarsherlock 就可以正常工作。

这是我的毕业典礼

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "org.myapps.android"
        minSdkVersion 9
        targetSdkVersion 17
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_5
            targetCompatibility JavaVersion.VERSION_1_5
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':menudrawer')
    compile project(':actionbarsherlock')
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.android.support:support-v4:21.0.3'
    compile files('libs/httpmime-4.1.2.jar')
    compile files('libs/tagsoup-1.2.1.jar')
    compile files('libs/volley.jar')
    compile files('libs/wordpresscom-android-rest-v0.0.3.jar')
}

它有点老旧的项目,但它就是我所需要的。在这些 gradle 中。我没有看到 appcombat 依赖项。那么如何从android studio中排除appcombat呢?

【问题讨论】:

  • 为什么两者都需要?
  • 仅供参考,您的依赖项列表中不需要两次 support-v4 依赖项。
  • 我只是发现 appcombat 也在 compile 'com.android.support:support-v4:21.0.3' 内部,哈哈。我对此完全陌生。我只是删除了“compile 'com.android.support:support-v4:21.0.3'”行,但仍然出现错误。我只是谷歌,发现 appcombat 也在“com.google.android.gms:play-services”内。那么如何从“com.google.android.gms:play-services”中排除appcombat?
  • 如果您排除它,您可能会遇到问题。这是有原因的依赖。 ABS 已被弃用,因为它已经过时,而 AppCompat 取代了它,所以你真的应该更加努力地进行迁移。

标签: android eclipse android-studio actionbarsherlock android-appcompat


【解决方案1】:

ActionBarSherlock 是 [DEPRECATED]

从您的项目中移除 ActionBarSherlock 并使用 Appcompat 库在旧版本上添加 actionBar。

appcompat 用法:

在你的 Gradle 文件中添加:

compile 'com.android.support:appcompat-v7:23.0.1'

在样式文件中设置 appcompat 作为你的父主题:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

从 AppCompatActivity 扩展您的活动:

public class MainActivity extends AppCompatActivity

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    相关资源
    最近更新 更多