错误:(773)属性" titleTextStyle"已定义

时间:2016-05-06 03:46:06

标签: android eclipse android-studio actionbarsherlock android-appcompat

我尝试将项目从 Eclipse 迁移到 Android Studio ,然后在Google搜索问题后我找到了答案here。不幸的是,我的应用需要 ActionBarSherlock 库和 appcompat-v7 。这在Eclipse中不是问题,那么为什么Android Studio会抱怨?此外,任何人都可以想到一个解决方案,而不是用替代品替换所需的 ActionBarSherlock 方法吗?我已经调查了这一点,我发现至少还有几周的工作时间,这会影响我的交付时间。

我的gradle文件如下所示:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}
apply plugin: 'android'

dependencies {
    compile project(':ActionBarSherlock:library')
    compile project(':HoloColorPicker')
    compile project(':Android-PullToRefresh:library')
    compile project(':ckChangeLog:library')
    compile files('libs/commons-io-2.0.1.jar')
    compile files('libs/htmlcleaner-2.2.jar')
    compile files('libs/jutf7-1.0.1-SNAPSHOT.jar')
    compile files('libs/jzlib-1.0.7.jar')
    compile files('libs/bugsense-3.6.jar')
    compile files('libs/apache-mime4j-dom-0.7.2.jar')
    compile files('libs/apache-mime4j-core-0.7.2.jar')
    compile 'com.android.support:appcompat-v7:23.3.0'
}

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

1 个答案:

答案 0 :(得分:-1)

首先,您必须删除lib并添加依赖项,然后将ActionBarSherlock替换为AppCompat,如下所示

代码替换:

  • SherlockActivity - > AppCompatActivity
  • SherlockFragmentActivity - > FragmentActivity
  • SherlockListActivity - > ListActivity(请参阅ListActivity / SherlockListActivity)
  • SherlockListFragment - > ListFragment;
  • getSupportMenuInflater - > getMenuInflater
  • getSherlockActivity() - > getActivity()
  • com.actionbarsherlock.widget.SearchView.OnQueryTextListener() - > OnQueryTextListener(参见SearchView)
  • m.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - > MenuItemCompat.setShowAsAction(m,MenuItem.SHOW_AS_ACTION_ALWAYS);
  

如果此更改无效,请尝试此https://stackoverflow.com/a/41243220/7235539