代码之家  ›  专栏  ›  技术社区  ›  Kumrun Nahar Keya

Java语言util。拉链ZipException:重复条目:net/sf/cglib/beans/BeanCopier$BeanCopierKey。班

  •  0
  • Kumrun Nahar Keya  · 技术社区  · 7 年前

    如何解决重复输入错误,我正在添加我的项目渐变详细信息以供参考。

    为了解决这个错误,我从中手动删除了cglib。gradle/caches/module-2/files-2.1/cglib,但在构建过程中,我发现jcenter再次创建lib。尝试退出该步骤失败

    下面是我的身材。应用程序内的gradle文件

        apply plugin: 'com.android.application'
    
    
    
    android {
        compileSdkVersion 25
        buildToolsVersion "26.0.1"
        defaultConfig {
            applicationId "com.example.keya.myapplication"
            minSdkVersion 15
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
    
        })
        /*androidTestCompile 'com.microsoft.appcenter:appium-test-extension:1.0'*/
        def appCenterSdkVersion = '1.1.0'
        compile "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
        compile "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        testCompile 'org.assertj:assertj-core:2.0.0'
        testCompile 'org.testng:testng:6.8.8'
        // https://mvnrepository.com/artifact/org.apache.james/apache-mime4j
        compile group: 'org.apache.james', name: 'apache-mime4j', version: '0.6.1'
        // https://mvnrepository.com/artifact/org.apache.commons/commons-exec
        compile group: 'org.apache.commons', name: 'commons-exec', version: '1.3'
    
        // https://mvnrepository.com/artifact/commons-codec/commons-codec
        compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
        // https://mvnrepository.com/artifact/commons-collections/commons-collections
        compile group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
        // https://mvnrepository.com/artifact/commons-io/commons-io
        compile group: 'commons-io', name: 'commons-io', version: '2.4'
        // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
        compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
        // https://mvnrepository.com/artifact/commons-logging/commons-logging
        compile group: 'commons-logging', name: 'commons-logging', version: '1.1.3'
        // https://mvnrepository.com/artifact/commons-validator/commons-validator
        compile group: 'commons-validator', name: 'commons-validator', version: '1.4.1'
        // https://mvnrepository.com/artifact/com.google.code.gson/gson
        compile group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
        // https://mvnrepository.com/artifact/com.google.guava/guava
        compile group: 'com.google.guava', name: 'guava', version: '18.0'
        // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
        compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.4.1'
        // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
        compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.1'
    // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime
        compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.4.1'
    
    
        compile 'com.android.support:support-annotations:25.0.1'
        compile 'com.beust:jcommander:1.27'
        testCompile 'info.cukes:cucumber-java:1.2.5'
        testCompile 'info.cukes:cucumber-junit:1.2.5'
        testCompile 'info.cukes:cucumber-picocontainer:1.2.2'
        compile 'com.android.support:support-v4:25.0.1'
        /*compile files('libs/appium-test-extension-1.0.jar')*/
        compile 'com.microsoft.appcenter:appium-test-extension:1.0'
    
    
    }
    
    
    apply plugin: 'maven'
    
    task createPom {
        pom {
            withXml {
                def dependenciesNode = asNode().appendNode('dependencies')
    
                //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
                configurations.testCompile.allDependencies.each {
                    def dependencyNode = dependenciesNode.appendNode('dependency')
                    dependencyNode.appendNode('groupId', it.group)
                    dependencyNode.appendNode('artifactId', it.name)
                            dependencyNode.appendNode('version', it.version)
                }
    
                def profilesNode = asNode().appendNode('profiles')
                profilesNode.append(new XmlParser().parse('https://raw.githubusercontent.com/Microsoft/AppCenter-Test-Appium-Java-Extensions/master/gradleuploadprofilesnippet.xml'))
            }
        }.writeTo("pom.xml")}
    

    在outside应用程序中,我有以下版本。gradle文件

        buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    有人能建议如何解决这个问题吗

    2 回复  |  直到 7 年前
        1
  •  0
  •   Lino    7 年前

    您应该确定哪些依赖项需要cglib库。可以使用以下gradle命令执行此操作:

    gradle dependencies
    

    然后,使用 exclude gradle指令。gradle文件从所有(除了一个)依赖项中删除cglib-lib。

        2
  •  0
  •   Kumrun Nahar Keya    6 年前

    所以基本上我通过检查依赖关系解决了这个问题

    ../gradlew dependenci
    

    然后发现cglib-lib有重复项,所以在应用程序构建中添加了以下行。gradle文件

    configurations {
        all*.exclude group: 'cglib', module: 'cglib'
    }
    

    从而解决了问题