Error:(254) Attribute "background" already defined with incompatible format

Error:(254) Attribute "background" already defined with incompatible format

在我的旧项目中我使用了 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.

您正在使用 actionbarsherlock,即 deprecated,并且会导致使用最新的 android 构建工具和支持 libraries.So、

时出现构建错误

移除

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

添加

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

不要使用 ActionBarSherlock,它已被弃用。请改用 support-lib。

roboguice-sherlock替换为AppCompat

1).删除所有包含 action bar

的代码

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 中自定义所有内容。