error: Attribute “***” has already been defined when using two library projects in Android

后端 未结 5 755
深忆病人
深忆病人 2020-12-30 01:13

I\'m using android-support-v7-appcompat as a library in my Android project. Now I want to include actionbarsherlock as another library proj

相关标签:
5条回答
  • 2020-12-30 01:52

    Remove the appcompact support library project from Properties = > Android

    0 讨论(0)
  • Gradle Resource Merger merges all resource folders from all dependencies and place into single folder. In case there are duplicates build process will fail.

    Fortunately, if you look below under Output: label, you will find the right path to the problem.

    Here is an example

    enter image description here

    in your case it is android-support-v7-appcompat\res\values\attrs.xml:476: error: Attribute "attributeName" has already been defined

    You can also build your project from command line and get the right path. attributeName Inside values\attrs.xml file on line 476 you would find a with property named "attributeName". Most probably it is your own styleable that you have to change to get rid of the duplicate.

    So now, when you know the reason, you can locate that property in your project module and replace it with different name.

    0 讨论(0)
  • 2020-12-30 02:01

    The correct way to solve this problem is by updating Android Support Libraries in all relevant projects and library projects. In my case I've used Android support library and also one of the library project to implement my application. When I update both libraries, the problem solved. The way of updating Android support library is;

    • Right click on the project
    • Select Android Tools from the pop up window
    • Select Add Support Library
    0 讨论(0)
  • 2020-12-30 02:10

    I updated the build tools version and resynced, it worked fine.

    0 讨论(0)
  • 2020-12-30 02:11

    I solved this by removing appcompact from project, and changing in styles to

    <style name="AppBaseTheme" parent="Theme.Sherlock">
    
    0 讨论(0)
提交回复
热议问题