Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

前端 未结 22 1422
不知归路
不知归路 2020-11-27 14:04

I am getting the following error while building the project. haven\'t used CoordinatorLayout in this project. just added as a dependency in build.gradle :

I am usin

相关标签:
22条回答
  • 2020-11-27 14:18

    This can happens when one library is loaded into gradle several times. Most often through other connected libraries.

    Remove a implementation this library in build.gradle

    Then Build -> Clear project

    and you can run the assembly)

    0 讨论(0)
  • 2020-11-27 14:19

    It worked when I downgrade the support appcompat gradle dependency, like follwing :

    implementation 'com.android.support:appcompat-v7:27.0.2'
    

    previously it was

    implementation 'com.android.support:appcompat-v7:27.1.0'
    

    OR

    Also this can be fixed by just adding support design dependency of version 27.1.0 or above to your app level build.gradle as following :

    implementation 'com.android.support:design:27.1.0'
    
    0 讨论(0)
  • 2020-11-27 14:19

    As android latest update doesn't support 'compile' keyword use 'implementation' in place inside your module build.gradle file.

    And check thoroughly in build.gradle for dependancy with + sign like this.

    implementation 'com.android.support:support-v4:28.+'
    

    If there are any dependencies like this, just update them with a specific version. After that:

    1. Sync gradle.
    2. Clean your project.
    3. Rebuild the project.
    0 讨论(0)
  • 2020-11-27 14:22

    Important Update

    Android support libraries will not be updated after 28.0.0. According to Support Library Release Notes -

    This will be the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX 1.0.0.

    So use AndroidX support libraries instead. In your case design library is now available in material package.

    dependencies {
        implementation 'com.google.android.material:material:1.0.0' // instead of design
        implementation 'androidx.appcompat:appcompat:1.0.2' // instead of support-v7
    }
    

    I have put latest versions in dependency, you can check latest version here at read time.

    Useful Posts :

    1. AndroidX introduction & integration
    2. Learn about Jetifier (engine behind AndroidX migration)
    3. Some Do's and Dont's
    0 讨论(0)
  • 2020-11-27 14:23

    Use the latest supportLibrary, version 27.1.1 to solve the problem. worked for me. (many bug fixes included - see changelog)

    0 讨论(0)
  • 2020-11-27 14:23

    I m using android studio 3.0 and i upgrade the design pattern dependency from 26.0.1 to 27.1.1 and the error is gone now.

    Add Following in gradle implementation 'com.android.support:design:27.1.1'

    0 讨论(0)
提交回复
热议问题