-1

I got this below error in gradle build Messages .I tried many Stackoverflow post relevant to this issue.But nothing worked for me.

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

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/IntegerRes.class

Edit:

app/build.gradle:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.golive.vernon"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true


    }

    dexOptions {
        //incremental = true;
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }

    packagingOptions {
        exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
        exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/gcm.jar')
    compile files('libs/glide-3.6.1.jar')
    compile files('libs/httpcore-4.3-beta1.jar')
    compile files('libs/httpmime-4.3.jar')
    compile files('libs/universal-image-loader-1.9.5.jar')
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile project(':facebook')
    compile project(':InstaLibrary')
    compile project(':simple-crop-image-lib')
    compile files('libs/twitter4j-core-4.0.4.jar')
    compile 'com.android.support:multidex:1.0.1'

}

Below I have added the libs screenshot:

enter image description here

Below I have added the dependencies list:

enter image description here

Manifest:

    >

Appcontroller.java:

@Override
public void onCreate() {
    super.onCreate();

    MultiDex.install(this);   

    mInstance = this;
}
Stephen
  • 9,899
  • 16
  • 90
  • 137
  • asked so many times ... guess what `compile fileTree(include: ['*.jar'], dir: 'libs')` + any `compile files('libs/xxxxxxxxx.jar')` does – Selvin Jun 27 '16 at 10:09

2 Answers2

1

In your Gradle Compile with support:multidex and add also dexOptions

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

useLibrary 'org.apache.http.legacy'

defaultConfig {
   ..............
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true


}
dexOptions {
    //incremental = true;
    preDexLibraries = false
    javaMaxHeapSize "4g"
}

packagingOptions {
    exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
    exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
 }

 dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile files('libs/gcm.jar')
compile files('libs/glide-3.6.1.jar')
compile files('libs/httpcore-4.3-beta1.jar')
compile files('libs/httpmime-4.3.jar')
compile files('libs/universal-image-loader-1.9.5.jar')
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile project(':facebook')
compile project(':InstaLibrary')
compile project(':simple-crop-image-lib')
compile files('libs/twitter4j-core-4.0.4.jar')
compile 'com.android.support:multidex:1.0.1'
 }

In Your AndroidManifest.xml add this lines android:name

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:name="android.support.multidex.MultiDexApplication"
    >

If also an error than compile

 compile 'com.google.android.gms:play-services:+'

Instead OF

   compile 'com.google.android.gms:play-services-maps:8.4.0'
Arjun saini
  • 4,223
  • 3
  • 23
  • 51
0

After followed Er. Arjun saini answer referred to adding multidex & licence and I have corrected adding facebook sdk to solve this issue:

previously, I had added the Facebook library by adding import module.

Wrong Way :

compile project(':facebook')

Right Way:

compile 'com.facebook.android:facebook-android-sdk:4.5.0'

And also In top-level build.gradle:

allprojects {
    repositories {
        jcenter()       // This is the default repo
        mavenCentral()  //  This is the Maven Central repo
    }
}
Stephen
  • 9,899
  • 16
  • 90
  • 137