How to import ActionBarSherlock using Gradle in An

2019-08-04 08:14发布

问题:

I'm trying to import ActionBarSherlock (ABS) into my Android app using Gradle, but unfortunately, when building I get a list of errors saying:

/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:248: error: Attribute "titleTextStyle" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:250: error: Attribute "subtitleTextStyle" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:256: error: Attribute "divider" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:258: error: Attribute "background" has already been defined
[etc. etc.]

* What went wrong:
Execution failed for task ':processDebugResources'.
> Could not call IncrementalTask.taskAction() on task ':processDebugResources'

I'm trying to import ABS using the following in build.gradle:

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.google.android.gms:play-services:4.0.30'
    instrumentTestCompile(files('libs/espresso-1.0-SNAPSHOT-bundled.jar'))
}

and in my settings.gradle I've got the following line:

include ':OurPackage', ':Libraries:ActionBarSherlock'

Does anybody know what I'm doing wrong? All tips are welcome!

回答1:

You are adding the same library twice.

From maven as aar format

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

From a local copy

include ':OurPackage', ':Libraries:ActionBarSherlock'

You have to remove the local copy, because in this way you are adding the same styles and attrs with same name twice.