0
 Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class 

Below is my app level gradle file. I tried removing appcompat, support v4, but it was no help. The app is working fine otherwise, I'm getting the error only when I'm trying to generate a signed apk.

buildsript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        applicationId "com.aubergine.resqv1"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 10109
        versionName "1.2.0"
        // Enabling multidex support.
        multiDexEnabled true

        // Flag to tell aapt to keep the attribute ids around
        aaptOptions {
            additionalParameters "--no-version-vectors"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
    //For Mint bug reporter
    maven { url "https://mint.splunk.com/gradle/" }
    //For bug report and crash report
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'http://maven.localytics.com/public' }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // libs for Material design
    // libs for dependency Injection
    // libs for Common font for Application
    //libs for calling api using Retrofit
    //For calling api using retrofit
    //For Mint bug reporter
    //For graph
    //libs for MaterialDesign EditText
    //For Circle Image
    //for universal image loader
    //For Number Picker in Estimated Time https://github.com/KasualBusiness/MaterialNumberPicker

    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }
    compile('com.digits.sdk.android:digits:2.0.5@aar') {
        transitive = true;
    }


    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.github.PhilJay:MPAndroidChart:v2.1.5'
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'biz.kasual:materialnumberpicker:1.2.0'
    compile 'com.google.android.gms:play-services-analytics:10.0.1'
    compile 'com.google.firebase:firebase-appindexing:10.0.1'
    compile 'com.facebook.stetho:stetho:1.4.2'
    compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
    compile 'com.shawnlin:number-picker:2.4.1'
    compile 'com.google.android.gms:play-services-ads:10.0.1'
    compile 'com.localytics.android:library:4.2.+'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    testCompile 'junit:junit:4.12'
}

Also, there are two CheckForNull class, infact there are duplicate classes in jsr-305. The screenshot:

screenshot

What would be a wise solution to this problem?

u32i64
  • 2,384
  • 3
  • 22
  • 36
  • It seems to me, that you there are at least two libraries in your `build.gradle`, which both have `javax` as their dependency (aka transitive dependency). So, you are importing two different versions of `javax` lib into your codebase, and that's why you have doublicated classes. Just look thtough all the dependencies `./gradlew app:dependencies` and find two libs that have dependency of `javax` and exclude that dependency for one of them. – azizbekian Feb 15 '17 at 14:43
  • See https://stackoverflow.com/a/22441017/192373 and other answers to this question – Alex Cohn Mar 14 '18 at 11:34
  • It's OK that jsr305 contains CheckForNull *et al.* twice: one entry is the source (java), the other is compiled (class). – Alex Cohn Mar 14 '18 at 11:34

1 Answers1

-1

Please do clean for gradle build using command ./gradlew clean.

JulienD
  • 7,102
  • 9
  • 50
  • 84
Samina
  • 1
  • 1