1

Help me in solving this issue as i am beginner in android ,i need some help..

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

java.io.IOException: Can't write [D:\bi.mobile\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\sort.Vijay.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson\2.8.0\c4ba5371a29ac9b2ad6129b1d39ea38750043eff\gson-2.8.0.jar(;;;;;;**.class)] (Duplicate zip entry [gson-2.8.0.jar:com/google/gson/annotations/Expose.class]))

This is my "build.gradle" file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26


    defaultConfig {
        applicationId "com.bimobile"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    // ..
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    //noinspection GradleCompatible,GradleCompatible
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'

    compile files('libs/android-async-http-1.4.4.jar')
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile files('libs/gson-2.8.0.jar')
    compile 'org.lucasr.twowayview:twowayview:0.1.4'
    compile "com.daimajia.swipelayout:library:1.2.0@aar"
}
android { sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/anim'] } } }
Community
  • 1
  • 1
s.vijay
  • 31
  • 8
  • 1
    Possible duplicate of [Error:Execution failed for task ':app:transformClassesWithDexForDebug'](https://stackoverflow.com/questions/33717886/errorexecution-failed-for-task-apptransformclasseswithdexfordebug) – Hemant Parmar Mar 22 '18 at 12:43

2 Answers2

0

On your gradle add this line compile 'com.android.support:multidex:1.0.0'

on your app singleton class add this extends MultiDexApplication

this should solve your problem.

  • @Hemant Parmar Thanks for your response ...But this solution didn't work for me...i am getting the same error again.... – s.vijay Mar 22 '18 at 12:57
  • ok, could you try removing this line `compile files('libs/gson-2.8.0.jar')`? you already have `compile 'com.google.code.gson:gson:2.8.0'` so the line i mentions before is not needed – Sergio Rodriguez Mar 22 '18 at 14:02
0

This is because you have multiple GSON dependencies in your project. You need to use only one. You should use only the library via maven with this:

compile 'com.google.code.gson:gson:2.8.0'

You should remove the following:

compile files('libs/gson-2.8.0.jar')

And don't forget to remove the gson-2.8.0.jar file in libs/ folder. Because you are including all the jar inside the libs with the following line:

compile fileTree(dir: 'libs', include: ['*.jar'])
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96