【问题标题】:Attribute "titleTextStyle" has already been defined?属性“titleTextStyle”已经定义了吗?
【发布时间】:2019-05-09 16:45:03
【问题描述】:

我已经将一个 eclipse android 项目导入到 android studio 1.2.2 我的项目的gradle:

dependencies {
    compile project(':unifiedPreferenceLib')
    compile project(':viewPagerIndicatorLib')
    compile project(':slidingUpFourSquare')
    compile project(':stylishDialogLib')
    compile project(':swipeListViewLib')
    compile project(':library')
    compile project(':textDrawLib')
    compile project(':cardview')
    compile project(':editTextFormLibrary')
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/CWAC-LocationPoller.jar')
    compile files('libs/Parse-1.8.0.jar')
    compile files('libs/ParseCrashReporting-1.8.0.jar')
    compile files('libs/android-support-v13.jar')
    compile files('libs/blurnavdrawerlib.jar')
    compile files('libs/bolts-android-1.1.4.jar')
    compile files('libs/google-http-client-1.15.0-rc.jar')
    compile files('libs/google-http-client-android-1.15.0-rc.jar')
    compile files('libs/google-http-client-jackson2-1.15.0-rc.jar')
    compile files('libs/loremipsum-1.0.jar')
    compile files('libs/splunk-mint-4.0.8.jar')
    compile files('libs/textdrawlib.jar')
}

我来了

错误:(1) 属性“titleTextStyle”已被定义

指向我的 colors.xml,但我的 xml 文件甚至没有具有这种属性的元素。

【问题讨论】:

    标签: android


    【解决方案1】:

    问题是'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' 定义了属性titleTextStyle,该属性也在另一个库中定义,因此冲突上升。

    其他人在添加 Action Bar Sherlock 后遇到了同样的问题(herehere),其中 appcompat-v7 已经有一个具有相同功能的操作栏(同样的 titleTextStyle 属性)。建议使用 appcompat-v7 中的 ActionBar 而不是 ActionBarSherlock。

    在您的情况下,appcompat v7 并未直接添加为依赖项

    this answer中所述

    Google Play 服务的最新版本现在使用 appcompat-v7,所以你 不能将它与 actionbarsherlock 一起使用。您必须只使用 appcompat-v7 或之前版本的播放服务:

    compile 'com.google.android.gms:play-services:7.0.0'
    

    您使用的是最新版本,因此冲突出现了。您可以按照建议仅使用 appcompat 或坚持使用 actionbarsherlock 并切换到 playservices 版本 7.0.0。

    查看the android support library features 我注意到他们会引导您:

    一般来说,我们建议包括 v4 支持和 v7 appcompat 库,因为它们支持广泛的 Android 版本和 为推荐的用户界面模式提供 API。

    这是不使用 actionbarsherlock 的另一个指示。

    【讨论】:

    • 我已经通过完全删除 actionBarSherlock 库解决了这个问题。我一直在使用的一个特定的库项目依赖于 actionbarsherlock。我调整了这个库来编译而不需要 actionbarsherlock。无论如何,您所说的似乎是正确的方法。所以奖励你,除非别人有更好的答案。
    • 如果我确实需要使用 2 个库来定义特定视图的属性,使用 declare-styleable ,但即使视图有不同的包,属性名称是一样的怎么办?我该如何处理?
    • @androiddeveloper 对于许多用户来说,这似乎是一个足够广泛的问题,因此值得提出自己的问题。在过去的 2 个月里,仅这个问题就受到了无数次点击。我建议您单独发布您的问题,我会在有时间时回答,除非其他人在此之前提供相关答案。干杯!
    • 编译 'com.google.android.gms:play-services:7.0.0' 解决了这个问题,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 2016-09-19
    • 2011-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    相关资源
    最近更新 更多