Android Studio Appcompat conflict with ActionBarSherlock [duplicate]

本秂侑毒 提交于 2020-01-07 03:25:07

问题


i try import eclipse project to android studio and get this error

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

and i figure it out appcombat is conflict with actionbarsherlock. i try to migrate from abs to appcombat but. seems the project i got is hardcoded with actionbarsherlock. so its imposible for me. i decide to exclude the appcombat so the actionbarsherlock work without conflict.

here's my gradle

    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')
}

its bit oldy project, but its all i need. in these gradle. i dont see the appcombat depencies. so how to exclude appcombat from android studio?


回答1:


ActionBarSherlock was [DEPRECATED]

remove ActionBarSherlock from your project and use Appcompat library to have actionBar on old versions.

appcompat usage:

in your Gradle file add:

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

in style file set appcompat as your parent theme:

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

extent your activity from AppCompatActivity:

public class MainActivity extends AppCompatActivity


来源:https://stackoverflow.com/questions/32466115/android-studio-appcompat-conflict-with-actionbarsherlock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!