-1

I have an error in my gradle:

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

java.io.IOException: Can't write [C:\Users\El-Othmane\Desktop\tes11\android2\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\El-Othmane.gradle\caches\transforms-1\files-1.1\support-core-ui-26.1.0.aar\744d5e6087e939bc5d55ea9f4d6a237d\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewPager$2.class])) enter code here Here is my gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.companyname.gamename"
        minSdkVersion 14
        targetSdkVersion 27
        multiDexEnabled true

        dexOptions {
            javaMaxHeapSize "4g"
        }

        ndk {
            moduleName "player_shared"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    sourceSets.main {
        jni.srcDirs = []// <-- disable automatic ndk-build call
    }
    productFlavors {
    }
}



dependencies {
    compile('com.google.android.gms:play-services:+') { exclude module: 'support-v4' }
    compile files('libs/dagger-1.2.2.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    compile files('libs/support-v4-19.0.1.jar')
}
InsaneCat
  • 2,115
  • 5
  • 21
  • 40

3 Answers3

0

First add this library in Gradle:

compile 'com.android.support:multidex:1.0.0'

Also you can add multidex:

multiDexEnabled true

and make your application to extend class MultiDexApplication.

Micer
  • 8,731
  • 3
  • 79
  • 73
  • Ther solution is exchange this compile 'com.android.support:multidex:1.0.0' with this compile files('libs/dagger-1.2.2.jar') compile files('libs/javax.inject-1.jar') compile files('libs/nineoldandroids-2.4.0.jar') compile files('libs/support-v4-19.0.1.jar') – 1523222 Views Apr 15 '18 at 17:07
  • classpath 'com.android.tools.build:gradle:3.1.2' use this in project –  Sep 25 '18 at 12:57
0

Put code like this:

     apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.companyname.gamename"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 4
        versionName "1.3"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    defaultConfig {
        multiDexEnabled true
    }
    useLibrary 'org.apache.http.legacy'
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.support:support-v4:25.4.0'
    compile files('libs/dagger-1.2.2.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    compile files('libs/support-v4-19.0.1.jar')
}
apply plugin: 'com.google.gms.google-services'

You are talking about how to exclude V4 See

Instead of V4 you can put V7 also like this

 compile 'com.android.support:appcompat-v7:25.4.0'

You got this error may be because of Prograurd Duplicate zip entry

check below Links1 , Links2

Hope this solved your problem.

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
0

The error is expected because you're using an old support library which is conflicted with your compileSdkVersion and Google play service. So, you need to change your build.gradle to something like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"
    defaultConfig {
        applicationId "com.companyname.gamename"
        minSdkVersion 14
        targetSdkVersion 27
        multiDexEnabled true

        dexOptions {
            javaMaxHeapSize "4g"
        }

        ndk {
            moduleName "player_shared"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    sourceSets.main {
        jni.srcDirs = []// <-- disable automatic ndk-build call
    }
    productFlavors {
    }
}

dependencies {
    compile files('libs/dagger-1.2.2.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    // Don't use the following
    //compile files('libs/support-v4-19.0.1.jar')
    // instead, use support library with the same version with your compileSdkVersion
    compile 'com.android.support:support-v4:27.1.1'

    // You should NOT use all the google play service
    // use what you need, please refer to https://developers.google.com/android/guides/setup
    compile 'com.google.android.gms:play-services:11.2.0'

}
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96