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

前端 未结 22 1421
不知归路
不知归路 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:13

    I faced the same problem, I added android support design dependencies to the app level build.gradle

    Add following:

    implementation 'com.android.support:design:27.1.0'
    

    in build.gradle. Now its working for me.

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

    I also faced same problem. But then I realised that the versions I am using of support libraries was not same.

    Once I made it same, the error gone.

    In your case

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

    are not same, so you just downgraded appcompat to

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

    hence, your problem solved.

    But you could also have solved if you could have upgraded support design version to

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

    Adding this to project's gradle.properties fixed it for us:

    android.enableJetifier=true
    android.useAndroidX=true
    
    0 讨论(0)
  • 2020-11-27 14:15

    Changed all dependencies to compile rather than implementation, then I rebuild the project without errors. Then I switched back to implementation rather than leaving it as compile.

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

    The solution for this is that remove this following dependency:

    implementation 'com.android.support:design:26.1.0'
    

    put general dependencies as:

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        //noinspection GradleCompatible
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:support-compat:26.1.0'
        implementation 'com.android.support:multidex:1.0.3'    
        implementation 'com.android.support:support-v4:26.1.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.facebook.android:audience-network-sdk:4.99.1'
    }
    
    0 讨论(0)
  • 2020-11-27 14:17

    Your build script should match with application build.gradle dependencies.

    ext {
            buildToolsVersion = "27.0.3"
            minSdkVersion = 16
            compileSdkVersion = 27
            targetSdkVersion = 26
            supportLibVersion = "27.1.1"
        }
    
    
    dependencies {
        .................
        ...................
    
        implementation 'com.android.support:support-v4:27.1.0'
        implementation 'com.android.support:design:27.1.0'
        ................
        ...........
    }
    

    if you want to downgrade dependencies then also downgrade supportLibVersion and buildToolsVersion .

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