简体   繁体   中英

Android Gradle build dependency error

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 (*)

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'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM