Error:(773) Attribute “titleTextStyle” has already

2019-08-15 06:09发布

问题:

I'm trying to migrate a project from Eclipse to Android Studio and after googling the problem I found an answer here. Unfortunately, my app requires both the ActionBarSherlock library and appcompat-v7. This wasn't a problem in Eclipse, so why should Android Studio complain? Also, can anyone think of a solution, short of replacing the needed ActionBarSherlock methods with alternatives? I've looked into that and I see at least a couple of weeks of work ahead, which would blow my delivery schedule.

My gradle file looks like this:

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:

First you have to remove lib and add dependencies and then replace from ActionBarSherlock to AppCompat like this

Code Replacements:

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

If this change not work then try this https://stackoverflow.com/a/41243220/7235539