4

When I build an APK file with android studio (version 2.0) for my project, there is a error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/oltu/oauth2/common/OAuth$ContentType.class

Here is my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    defaultConfig {
        applicationId "com.db.android.app.denhathai"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 14
        versionName "1.2.2"
        multiDexEnabled true

        manifestPlaceholders = [manifestApplicationId          : "${applicationId}",
                                onesignal_app_id               : "bad49395-e355-4802-8df1-414be2d345ac",
                                onesignal_google_project_number: "1071797880741"]
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    }

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:design:+'
    compile 'com.google.android.gms:play-services-ads:+'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.6'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.onesignal:OneSignal:2.+@aar'
    compile 'com.google.android.gms:play-services-gcm:+'
    compile 'com.google.android.gms:play-services-analytics:+'
    compile 'com.google.android.gms:play-services-location:+'
    compile 'com.thefinestartist:finestwebview:1.2.1'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.github.franmontiel:PersistentCookieJar:1c351f68d3'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.0.0-RC1'
    compile 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1'
    }
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
NghiaDao
  • 383
  • 1
  • 3
  • 14
  • I got same error yesterday resolved by removing redundant support-v4 library in my case, if you have any remove it. – Nisarg Apr 26 '16 at 04:21

3 Answers3

13

Try changing your dependency

compile 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1'

to

compile ("org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1"){
    exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
}
Panduka DeSilva
  • 817
  • 9
  • 12
2

It is caused because you have included a library as a compile dependency and also included it in your projects libs folder. Go to your projects libs folder and delete the duplicate .jar files.

Nongthonbam Tonthoi
  • 12,667
  • 7
  • 37
  • 64
1

In terminal execute in root project folder:

./gradlew clean
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85