• Register
0 votes
84 views

Problem :

I am facing the following issue while building my project. I haven't used any CoordinatorLayout in my project. I have just added it as a dependency in my build.gradle :

I am currently using Android Studio 3.2 Canary 4.

My Error as follows :

AGPBI: {"kind":"error","text":"Program type already present: android.support.design.widget.CoordinatorLayout$Behavior","sources":[{}],"tool":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /windows/Other/app/build/intermediates/transforms/dexBuilder/debug/2.jar, /windows/Other/app/build/intermediates/transforms/dexBuilder/debug/6.jar, /windows/Other/app/build/intermediates/transforms/dexBuilder/debug/8.jar, . . ...................

/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/304.jar

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

7.5k points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

To resolve your issue please use the following approach:

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

Please Don't do like following :

implementation 'com.android.support:appcompat-v7:27.+'

It may give you the error and so don't use the older version than this.

or even don't do like following :

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1' 

more numbers of libraries and then

implementation 'com.android.support:appcompat-v7:27.+'

the same library but it has a different version, it may give you an error.

If above approach doesn’t help the follow this one:

Your build script must match with the application build.gradle dependencies as shown below:.

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 also want to downgrade your dependencies then also downgrade the supportLibVersion and buildToolsVersion

38.6k points
0 votes

Solution:

It performed at thr time I downgrade the support appcompat gradle dependency, like follwing :

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

Formerly it was

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

OR

Further this can be solved by only including 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'

I faced the similar issue, I included android support design dependencies to the app level build.gradle

Include following:

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

in build.gradle. Now its performing for me.

It might be reason of a library, I faced it cause of Glide.

It was

implementation 'com.github.bumptech.glide:glide:4.7.1'

So I included exclude group: "com.android.support" And it becomes

implementation ('com.github.bumptech.glide:glide:4.7.1') {
        exclude group: "com.android.support"
    }

Ensure that these two are the same version in your app level build.gradle file

 implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'

Personally, I include the following line to my app/build.gradle:

implementation "com.android.support:design:${rootProject.ext.supportLibVersion}"

I am employing 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.

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

Employ

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

Don't usage like

implementation 'com.android.support:appcompat-v7:27.+'

It may give you an error and don't usage an older version than this.

or event don't do 

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1' 

 numbers of libraries and then

implementation 'com.android.support:appcompat-v7:27.+'

the similar library however it has a different version, it can give you an error.

31.7k points
edited by