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

I get the following error when building a project. did not use CoordinatorLayout in this project. just added as a dependency in build.gradle:

I am using Android Studio 3.2 Canary 4.

Logcat

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

com.android.builder.dexing.DexArchiveMergerException: error when merging dex archives: /windows/Other/app/build/intermediates/transforms/dexBuilder/debug/0.jar,/windows/Others/app/build/intermediate/intermediate / transforms / dexBuilder / debug / 1.jar, / windows / Other / app / build / intermediates / transforms / dexBuilder / debug / 4.jar ,. , ...................

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

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

build.gradle

apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { applicationId "com.dagkot" minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField "String", "BASE_URL", "\"http://api.openweathermap.org/data/2.5/\"" buildConfigField "String", "API_KEY", "\"435e9075f348868c2714fe7c6895efa5\"" } debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField "String", "BASE_URL", "\"http://api.openweathermap.org/data/2.5/\"" buildConfigField "String", "API_KEY", "\"xxxx\"" } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', { exclude group: 'com.android.support', module: 'support-annotations' }) implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // Dagger dependencies compileOnly 'org.glassfish:javax.annotation:10.0-b28' implementation "com.google.dagger:dagger:$rootProject.daggerVersion" implementation "com.google.dagger:dagger-android:$rootProject.daggerVersion" implementation "com.google.dagger:dagger-android-support:$rootProject.daggerVersion" kapt "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion" kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion" //Butterknife dependencies implementation 'com.jakewharton:butterknife:8.8.1' kapt 'com.jakewharton:butterknife-compiler:8.8.1' // Architecture Components Dependencies kapt "android.arch.lifecycle:compiler:$rootProject.lifeCycle" implementation "android.arch.lifecycle:extensions:$rootProject.lifeCycle" implementation "android.arch.lifecycle:reactivestreams:$rootProject.lifeCycle" implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion" // Retrofit/RxJava Dependencies implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion" implementation "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofitVersion" implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion" implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxAndroidVersion" implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0' implementation 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.1.1' // GSON implementation "com.google.code.gson:gson:$rootProject.gsonVersion" // Rx Location Manager implementation 'io.nlopez.smartlocation:library:3.3.3' implementation 'io.nlopez.smartlocation:rx:3.3.1' //Anko Dependencies implementation "org.jetbrains.anko:anko-commons:$rootProject.anko_version" implementation "org.jetbrains.anko:anko-design:$rootProject.anko_version" implementation 'com.android.support:design:27.0.2' implementation("com.github.hotchemi:permissionsdispatcher:3.1.0") { // if you don't use android.app.Fragment you can exclude support for them exclude module: "support-v13" } kapt "com.github.hotchemi:permissionsdispatcher-processor:3.1.0" } 
+125
source share
25 answers

This worked when I lowered the gradle dependency of appcompat support, for example:

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

earlier it was

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

OR

You can also fix this by simply adding a design support dependency of version 27.1.0 or higher to your build.gradle level of the application as follows:

 implementation 'com.android.support:design:27.1.0' 
+214
source

I ran into the same issue, I added Android support design dependencies at build.gradle application build.gradle

Add the following:

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

in build.gradle. Now it works for me.

+77
source

This may be the cause of the library, I came across this because of Glide.

It was

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

So I added an exclude group: "com.android.support" and it becomes

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

Make sure these two versions match in your application level build.gradle file.

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

I think this should solve the problem

+13
source

Use the latest supportLibrary version 27.1.1 to resolve the problem. worked for me. (many bugs fixed - see list of changes )

+12
source

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

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

With this syntax, the version is dynamic.

+9
source

using

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

Do not use as

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

This can lead to an error and not use an older version than this.

or event is wrong

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

etc ... library numbers and then

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

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

+6
source

I am using Android Studio 3.0 and I am updating the design pattern dependency from 26.0.1 to 27.1.1 and the error has disappeared.

Add the following to implementation 'com.android.support:design:27.1.1' gradle implementation 'com.android.support:design:27.1.1'

+6
source

I am lowering support

 previously it was implementation 'com.android.support:appcompat-v7:27.0.2' 

Use it

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

Happy Codng Works

+4
source

Important update

Android support libraries will not be updated after 28.0.0 . According to the support library release notes -

This will be the latest release of the feature in the android.support package , and developers are advised to upgrade to AndroidX 1.0.0 .

So use the AndroidX support libraries instead . In your case, the design library is now available in packaging materials.

 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 put the latest versions in a dependency, you can check the latest version here while reading.

Useful posts:

  1. AndroidX introduction and integration
  2. Learn about Jetifier (AndroidX Migration Engine)
  3. Some do and do not
+4
source

I also had this problem; and I decided that this way:

 configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '26.0.1' } } } } 

be careful, my min SDK was 26, you have to change it with yours!

+2
source

I know this is a late answer, but I had the same problem and my solution was to simply add implementation 'com.android.support:design:28.0.0 or any implementation 'com.android.support:design:28.0.0 the above design library support !!

+2
source

"Program type already exists" Delete the contents of the / build directory, it has some Dex (?) Problem with the generated binaries. Got these answers just like you, they helped solve this problem, but created a lot of others. Removing assembly contents works for everyone.

+2
source

Since the latest Android update does not support the "compile" keyword, use the "implementation" inside your module build.gradle file.

And carefully check in build.gradle for a + sign like this.

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

If there are such dependencies, just upgrade them to a specific version. After that:

  1. Sync Gradle.
  2. Clean your project.
  3. Rebuild the project.
+1
source

The solution for this is to remove this following dependency:

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

put general dependencies like:

 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' } 
+1
source

I got this error after updating com.android.support.constraint:constraint-layout from 1.1.0 to 1.1.3. Maybe worth a try.

+1
source

Adding this to the gradle.properties project fixed this for us:

 android.enableJetifier=true android.useAndroidX=true 
+1
source

Your build script must match the build.gradle application 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 lower dependencies then also lower supportLibVersion and buildToolsVersion.

+1
source

I also ran into the same problem. But then I realized that the versions of the support libraries I used did not match.

As soon as I did the same, the error disappeared.

A case of you

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

not the same so you just downgraded appcompat to

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

therefore, your problem is resolved.

But you could also decide if you could upgrade the support design version to

 implementation 'com.android.support:design:27.1.0' 
+1
source

If any of the answers mentioned here do not work, go to File> Invalidate Catches / Restart

0
source

In my case, the problem was that I already had a jar file in the lib / folder. Removing this solved the problem.

So check if there is a jar in your folder:

  find . -name *.jar 

If it is in the lib folder, try deleting it

0
source

Go to the directory where you put the additional libraries and delete the duplicated libraries.

0
source

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

Remove the implementation of this library in build.gradle

Then build -> clean project

and you can run the build)

0
source

You need to clean the project so that it is rebuilt correctly. In Android Studio menu: Build β†’ Clean Project

-1
source

All dependencies for compilation, not for implementation, are changed, then I rebuild the project without errors. Then I returned to the implementation, and did not leave it as a compilation.

-1
source

Source: https://habr.com/ru/post/1275711/


All Articles