库冲突错误

时间:2016-08-03 11:25:55

标签: android gradle maps conflicting-libraries

我有这个错误:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/iid/zzb$zza$zza.class

当我使用

compile 'com.google.android.gms:play-services-maps:9.4.0'

compile 'com.google.android.gms:play-services-maps:8.4.0'一切正常。

现在正在同步确定,但是当我尝试运行该项目时,我收到了此错误。

这是我的完整build.gradle:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://download.crashlytics.com/maven' }
        maven {
            url releasesRepoUrl
            credentials {
                username releasesRepoUsername
                password releasesRepoPassword
            }
        }
        maven {
            url snapshotsRepoUrl
            credentials {
                username snapshotsRepoUsername
                password snapshotsRepoPassword
            }
        }
        maven {
            url thirdPartyRepoUrl
            credentials {
                username thirdPartyRepoUsername
                password thirdPartyRepoPassword
            }
        }
    }

    dependencies {
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
        classpath 'com.xxx:android-variantSelector-gradle-plugin:1.0'
        classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'org.robolectric'
apply plugin: 'crashlytics'
apply plugin: 'sonar-runner'
apply plugin: 'com.xxx.android.variantSelector'

androidVariantSelector {
    moveOutputEnabled true
    outputDirectoryPath "appstoreDelivery"
    renameOutputEnabled true
}

android.applicationVariants.all { variant ->

    variant.mergeResources.doFirst {
        def buildType = java.lang.System.getenv("BUILD_TYPE") ?: java.lang.System.getProperty("BUILD_TYPE") ?: 'debug'
        android.sourceSets[buildType].res.srcDirs = ["configs/$buildType"]
    }
}

android {
    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.xxx.androidapp"
        minSdkVersion 10
        targetSdkVersion 23
        multiDexEnabled  true
        archivesBaseName = "xxx-appli-android";
    }

    signingConfigs {
        release {
            storeFile file("code-signing/distribution/ter.keystore")
            storePassword "tersncf2012"
            keyAlias "ter"
            keyPassword "tersncf2012"
        }

    }

    lintOptions {
        checkReleaseBuilds false
    }

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

        debug {
            if (System.properties.getProperty('coverage')) {
                testCoverageEnabled = true
            }
        }
    }

    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    sourceSets {

        androidTest.setRoot('src/test')
        instrumentTest.setRoot('src/test')
    }
}

def bkFrameworkVersion = '2.1.2@aar-SNAPSHOT'

dependencies {

    compile project(':xxx-android-library')

    // 3rd party libs
    compile('com.crashlytics.android:crashlytics:1.+') {
        exclude module: 'support-v4'
    }

    // Bk framework libs
    compile(group: 'com.xxx.bkdroid', name: 'bk-ui-adapters', version: bkFrameworkVersion) {
        exclude module: 'support-v4'
    }
    compile(group: 'com.xxx.bkdroid', name: 'bk-ui-utils', version: bkFrameworkVersion) {
        exclude module: 'support-v4'
    }
    compile(group: 'com.xxx.bkdroid', name: 'bk-ui-remoteimageview', version: bkFrameworkVersion) {
        exclude module: 'support-v4'
    }
    compile(group: 'com.xxx.bkdroid', name: 'bk-ui-pagecontrol', version: bkFrameworkVersion) {
        exclude module: 'support-v4'
    }
    compile(group: 'com.xxx.bkdroid', name: 'bk-ui-pagecontrol', version: bkFrameworkVersion) {
        exclude module: 'support-v4'
    }
    compile files('libs/com.radaee.pdfex_view.jar')
    compile files('libs/gcm.jar')
    compile files('libs/dom4j.jar')
    compile files('libs/libGoogleAnalytics.jar')
    compile files('libs/library-2.4.0.jar')
    //compile files('libs/urbanairship-lib-3.2.1.jar')

    // Test ....
    androidTestCompile files('testLibs/maps.jar')
    androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
    androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
    androidTestCompile 'org.hamcrest:hamcrest-library:1.1'
    androidTestCompile('junit:junit:4.+') {
        exclude module: 'hamcrest-core'
    }
    androidTestCompile('org.robolectric:robolectric:2.4') {
        exclude module: 'classworlds'
        exclude module: 'commons-logging'
        exclude module: 'httpclient'
        exclude module: 'maven-artifact'
        exclude module: 'maven-artifact-manager'
        exclude module: 'maven-error-diagnostics'
        exclude module: 'maven-model'
        exclude module: 'maven-project'
        exclude module: 'maven-settings'
        exclude module: 'plexus-container-default'
        exclude module: 'plexus-interpolation'
        exclude module: 'plexus-utils'
        exclude module: 'support-v4'
        exclude module: 'wagon-file'
        exclude module: 'wagon-http-lightweight'
        exclude module: 'wagon-provider-api'
    }
    androidTestCompile 'com.squareup:fest-android:1.0.+'

    compile 'com.facebook:facebook-android-sdk:3.5.+@aar'
    compile 'org.sufficientlysecure:html-textview:1.5'
    compile 'com.android.support:support-v4:23.+'

    // Urban Airship SDK
    compile 'com.urbanairship.android:urbanairship-sdk:7.1.3'

    // Recommended for in-app messaging
    compile 'com.android.support:cardview-v7:23.3.0'

    // Recommended for location services
    compile 'com.google.android.gms:play-services-maps:9.4.0'
}

sonarRunner {
    sonarProperties {
        property "sonar.dynamicAnalysis", "reuseReports"
        property "sonar.java.coveragePlugin", "jacoco"
        property "sonar.jacoco.reportPath", "build/jacoco/testDebug.exec"
        property "sonar.host.url", "http://sonar.backelite.com"
        property "sonar.jdbc.url", "jdbc:mysql://thriller:3306/sonar?useUnicode=true&characterEncoding=utf8"
        property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
        property "sonar.jdbc.username", sonarDatabaseUserName
        property "sonar.jdbc.password", sonarDatabasePassword
        property "sonar.projectKey", "ter--appli-android"
        property "sonar.projectName", "TER Android"
        property "sonar.projectVersion", "1.6.3"
        properties["sonar.sources"] = android.sourceSets.main.java.srcDirs
        properties["sonar.tests"] = android.sourceSets.androidTest.java.srcDirs
        properties["sonar.binaries"] = file("build/intermediates/classes/debug")
        property "sonar.language", "java"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.profile", "Android Lint"
        property "sonar.scm.url", "scm:svn:http://subversion.backelite.com/backelite/ter/ter-appli-android/trunk"
        property "sonar.verbose", "true"
        property "protectedAllowed", "true"
        property "sonar.junit.reportsPath", "build/test-results"
        property "sonar.exclusions", "**/radaee/**"
    }
}

apply plugin: 'idea'

idea {
    module {
        testOutputDir = file('build/test-classes/debug')
    }
}

apply plugin: 'jacoco'

jacoco {
    toolVersion = "0.7.1.201405082137"
}

def coverageSourceDirs = [
        '../app/src/main/java'
]

task jacocoTestReport(type: JacocoReport) {
    group = "Reporting"

    description = "Generate Jacoco coverage reports"

    classDirectories = fileTree(
            dir: '../app/build/intermediates/classes/debug',
            excludes: ['**/R.class',
                       '**/R$*.class',
                       '**/*$ViewInjector*.*',
                       '**/*$Provide*.*',
                       '**/*$Inject*.*',
                       '**/*$Module*.*',
                       '**/BuildConfig.*',
                       '**/Manifest*.*']
    )

    additionalSourceDirs = files(coverageSourceDirs)
    sourceDirectories = files(coverageSourceDirs)
    executionData = files('../app/build/jacoco/testDebug.exec')

    reports {
        xml.enabled = true
        html.enabled = true
    }
}

这是我的xxx-android-library gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

version = '1.2@aar-SNAPSHOT'
group = 'com.ter.androidlib'

repositories {
    mavenCentral()
    maven {
        url releasesRepoUrl
        credentials {
            username releasesRepoUsername
            password releasesRepoPassword
        }
    }
    maven {
        url snapshotsRepoUrl
        credentials {
            username snapshotsRepoUsername
            password snapshotsRepoPassword
        }
    }
    maven {
        url thirdPartyRepoUrl
        credentials {
            username thirdPartyRepoUsername
            password thirdPartyRepoPassword
        }
    }
    maven {
        url 'http://download.crashlytics.com/maven'
    }
    maven {
        url "http://JRAF.org/static/maven/2"
    }
    maven {
        url "http://mente.github.io/facebook-api-android-aar"
    }

}

android {
    compileSdkVersion 16
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 15
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

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

    sourceSets {

        main {

         manifest {
            srcFile 'AndroidManifest.xml'
         }

         java {
            srcDir 'src'
         }

         res {
            srcDir 'res'
         }

         assets {
            srcDir 'assets'
         }

         resources {
            srcDir 'src'
         }

         aidl {
            srcDir 'src'
         }

     }

 }
}

def bkFrameworkVersion = '2.1.2@aar-SNAPSHOT'

dependencies {
    compile (group: 'com.xxx.bkdroid', name: 'bk-core', version: bkFrameworkVersion)
    compile (group: 'com.xxx.bkdroid', name: 'bk-ui-adapters', version: bkFrameworkVersion)
    compile (group: 'com.xxx.bkdroid', name: 'bk-ui-utils', version: bkFrameworkVersion)
    compile (group: 'com.xxx.bkdroid', name: 'bk-utils', version: bkFrameworkVersion)
    compile (group: 'com.xxx.bkdroid', name: 'bk-utils-log', version: bkFrameworkVersion)
    compile (group: 'com.xxx.bkdroid', name: 'bk-jackson', version: bkFrameworkVersion)
    compile (group: 'com.xxx.bkdroid', name: 'bk-db', version: bkFrameworkVersion)
    compile (group: 'com.xxx.bkdroid', name: 'bk-network-webservice', version: bkFrameworkVersion)
}

uploadArchives {

    repositories {

        mavenDeployer {
            repository(url: releasesRepoUrl) {
                authentication(userName: releasesRepoUsername, password: releasesRepoPassword)
            }

            snapshotRepository(url: snapshotsRepoUrl) {
                authentication(userName: snapshotsRepoUsername, password: snapshotsRepoPassword)
            }

            pom.project {
                name 'XXX Library for Android'
                packaging 'aar'
            }

        }

    }

}

0 个答案:

没有答案