错误:(254)属性"背景"已经使用不兼容的格式定义

时间:2016-12-15 12:17:54

标签: android actionbarsherlock android-appcompat

在我的旧项目中,我使用了roboguice-sherlockactionbarsherlock,现在我还要实现com.android.support:appcompat-v7com.android.support:design但是当我尝试添加这两个依赖项时gradle我得到了下面给出的这个错误。 我也尝试替换它,但在某些情况下,必须使用sherlock

Error:(254) Attribute "background" already defined with incompatible format.
Error:(130) Original attribute defined here.
Error:(481) Attribute "navigationMode" already defined with incompatible format.
Error:(241) Original attribute defined here.
Error:(489) Attribute "displayOptions" already defined with incompatible format.
Error:(247) Original attribute defined here.
Error:(502) Attribute "itemBackground" already defined with incompatible format.
Error:(474) Original attribute defined here.
Error:(505) Attribute "actionBarSize" already defined with incompatible format.
Error:(297) Original attribute defined here.
Error:(507) Attribute "windowMinWidthMajor" already defined with incompatible format.
Error:(296) Original attribute defined here.
Error:(507) Attribute "windowMinWidthMinor" already defined with incompatible format.
Error:(296) Original attribute defined here.
Error:(254) Attribute "background" already defined with incompatible format.
Error:(130) Original attribute defined here.
Error:(481) Attribute "navigationMode" already defined with incompatible format.
Error:(241) Original attribute defined here.
Error:(489) Attribute "displayOptions" already defined with incompatible format.
Error:(247) Original attribute defined here.
Error:(502) Attribute "itemBackground" already defined with incompatible format.
Error:(474) Original attribute defined here.
Error:(505) Attribute "actionBarSize" already defined with incompatible format.
Error:(297) Original attribute defined here.
Error:(507) Attribute "windowMinWidthMajor" already defined with incompatible format.
Error:(296) Original attribute defined here.
Error:(507) Attribute "windowMinWidthMinor" already defined with incompatible format.
Error:(296) Original attribute defined here.

3 个答案:

答案 0 :(得分:3)

roboguice-sherlock 替换为 AppCompat

1)。删除包含操作栏的所有代码

2)。下载https://github.com/rtyley/roboguice-sherlock源代码并将此包装 com.github.rtyley.android.sherlock 硬编码代码放入项目中

3)。删除依赖项:

1. compile 'com.github.rtyley:roboguice-sherlock:1.5'
2. compile 'com.actionbarsherlock:actionbarsherlock:4.4.0aar' 

4)。添加依赖项:

1. compile 'com.android.support:appcompat-v7:25.0.1'
2. compile 'com.android.support:design:25.0.1'

5)。在 roboguice-sherlock 中将某些文件 extandes更改为

1. class SherlockAccountAuthenticatorActivity extends AppCompatActivity
2. class RoboSherlockActivity extends AppCompatActivity
3. class RoboSherlockFragmentActivity extends FragmentActivity
4. class RoboSherlockListActivity extends ListActivity
5. class RoboSherlockPreferenceActivity extends PreferenceActivity
6. class RoboSherlockDialogFragment extends DialogFragment
7. class RoboSherlockFragment extends Fragment
8. class RoboSherlockListFragment extends ListFragment

6)。 AppCompat准备就绪。现在,您可以在appCompat中自定义所有内容。

答案 1 :(得分:2)

您正在使用actionbarsherlock deprecated,并且会在最新的Android构建工具和支持库中导致构建错误。所以,

删除

compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

添加

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

答案 2 :(得分:0)

不要使用ActionBarSherlock,不推荐使用它。请改用support-lib。