0

I got an error when build my android project:

Error:java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class

This class is included in jsr305-1.3.9.jar and appengine-endpoints-deps-1.9.18.jar.

I tried to exclude jsr305 library but it did not help. Help me please.

My module build.gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
  compile ('com.google.appengine:appengine-endpoints:1.9.18') {
      exclude module: 'google-http-client'
      exclude module: 'appengine-api-1.0-sdk'
  }
  compile ('com.google.appengine:appengine-endpoints-deps:1.9.18') {
      exclude module: 'jsr305'
  }
}

appengine {
  downloadSdk = true
  appcfg {
    oauth2 = true
  }
  endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
  }
}

My main build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.udacity.gradle.builditbigger"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries true
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_7
        targetCompatibility = JavaVersion.VERSION_1_7
    }

}

dependencies {

    compile project(':libjokes')
    compile project(':mylibrary')
    compile project (':backend')
    // Added for AdMob
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile project(path: ':backend', configuration: 'android-endpoints')
}

My dependency tree:

_releaseApk - ## Internal use, do not manually configure ##
+--- com.android.support:multidex:1.0.1
+--- project :libjokes
+--- project :mylibrary
|    \--- com.android.support:appcompat-v7:23.1.1
|         \--- com.android.support:support-v4:23.1.1
|              \--- com.android.support:support-annotations:23.1.1
+--- project :backend
|    +--- com.google.appengine:appengine-endpoints:1.9.18
|    |    \--- com.google.appengine:appengine-api-1.0-sdk:1.9.18
|    +--- com.google.appengine:appengine-endpoints-deps:1.9.18
|    \--- com.google.api-client:google-api-client-android:1.19.0
|         +--- com.google.api-client:google-api-client:1.19.0
|         |    +--- com.google.oauth-client:google-oauth-client:1.19.0
|         |    |    +--- com.google.http-client:google-http-client:1.19.0
|         |    |    |    \--- com.google.code.findbugs:jsr305:1.3.9
|         |    |    \--- com.google.code.findbugs:jsr305:1.3.9
|         |    +--- com.google.http-client:google-http-client-jackson2:1.19.0
|         |    |    +--- com.google.http-client:google-http-client:1.19.0 (*)
|         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.1.3
|         |    \--- com.google.guava:guava-jdk5:13.0
|         \--- com.google.http-client:google-http-client-android:1.19.0
|              \--- com.google.http-client:google-http-client:1.19.0 (*)
\--- com.google.android.gms:play-services-ads:8.4.0
     \--- com.google.android.gms:play-services-basement:8.4.0
          \--- com.android.support:support-v4:23.0.0 -> 23.1.1 (*)
4
  • Try to rebuild your project. Commented Feb 18, 2016 at 15:39
  • Try this solution link Commented Feb 18, 2016 at 15:48
  • rebuild project does`t help me Commented Feb 18, 2016 at 15:50
  • This solution is also valid. Good luck! Commented Feb 18, 2016 at 16:04

1 Answer 1

1

Fixed with:

configurations {
    all*.exclude module: 'jsr305'
}

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
    compile('com.google.appengine:appengine-endpoints:1.9.18') {
        exclude module: 'appengine-api-1.0-sdk'
    }
    compile('com.google.appengine:appengine-endpoints-deps:1.9.18') {
        exclude module: 'google-http-client'
    }
    compile 'javax.servlet:servlet-api:2.5'
}
Sign up to request clarification or add additional context in comments.

1 Comment

For me, the exlude of the module makes the app compile, but I the app crash on startup due to low memory which is insane. So excluding it makes the compiled apk memory consumpting drastically increasing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.