The gradle build completes successfully , but while running the application or trying to build the apk I am getting an error:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. java.io.IOException: Can't write [F:\\TravEz\\app\\build\\intermediates\\multi-dex\\debug\\componentClasses.jar] (Can't read [C:\\Users\\hp.gradle\\caches\\transforms-1\\files-1.1\\support-core-ui-27.1.0.aar\\51b8cdc0bcfc98652d9ae95f70697b30\\jars\\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))
I have tried all the methods mentioned here
Here is my project level gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io"}
//Glomadrian maven for animated switch
maven { url "https://dl.bintray.com/glomadrian/maven"}
maven { url "http://dl.bintray.com/lukaville/maven"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my app level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.travez.travez"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
compile 'com.github.florent37:materialtextfield:1.0.7'
//library for cardview
implementation 'com.android.support:cardview-v7:26.1.0'
//library for dialog box
implementation 'com.github.d-max:spots-dialog:0.7@aar'
//library for animated switch
implementation 'com.github.glomadrian:MaterialAnimatedSwitch:1.1@aar'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//Firebase authentication library
implementation 'com.google.firebase:firebase-auth:11.0.4'
//Firebase database library
implementation 'com.google.firebase:firebase-database:11.0.4'
//Google play services and maps libraries
implementation 'com.google.android.gms:play-services-maps:11.0.4'
implementation 'com.google.android.gms:play-services:11.0.4'
implementation 'com.google.android.gms:play-services-location:11.0.4'
//Geofire library
compile 'com.firebase:geofire-android:2.3.0'
//Runtime perission library
compile 'com.github.karanchuri:PermissionManager:0.1.0'
//Material Edit Text library
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
//Calligraphy library
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
// CircleView library
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'com.android.support:multidex:1.0.0'
compile 'com.nbsp:library:1.8'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
Is written twice, remove one of them.
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
Replace the + with the current version of the library
The problem is because you have duplicated support library in your dependencies.
android-image-cropper is using support library 27+, you can check its build.gradle . MaterialEditText is using support library 22.2.0
. Material Animated Switch is using support library 22.2.0
. You need to exlude the support libraries from them.
So, instead using the following:
compile 'com.github.florent37:materialtextfield:1.0.7'
implementation 'com.github.glomadrian:MaterialAnimatedSwitch:1.1@aar'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
use the following:
implementation 'com.android.support:support-annotations:26.1.0'
implementation ('com.github.florent37:materialtextfield:1.0.7') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
exclude module: 'support-annotations'
}
implementation ('com.github.glomadrian:MaterialAnimatedSwitch:1.1@aar') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
implementation ('com.theartofdev.edmodo:android-image-cropper:2.6.0') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
You can check the dependencies tree if you still found the conflicted libraries with:
./gradlew app:dependencies
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.