Android项目构建成功,但运行失败,出现错误:java.util.zip.ZipException:重复条目 [英] Android project build successfully but ran failed with error: java.util.zip.ZipException: duplicate entry

查看:261
本文介绍了Android项目构建成功,但运行失败,出现错误:java.util.zip.ZipException:重复条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经更新了我的android studio和SDK以及项目等级上的一些软件包依赖关系,从那以后,我遇到了很多问题,我认为原因是依赖关系之间不兼容。

在我研究的过程中,我发现很多人都有同样的问题,这并不罕见。我已经解决了一些错误,但问题却一个接一个出现,我只是感到困惑。希望你能帮我找出问题及其解决方案。



代码适用于新的android版本! (有点奇怪),我可以在android 21+上编译和运行应用程序。但是当我尝试在21以下的Android版本上运行它时,它会给我一个错误。在我迁移到Android Studio 2之前,每件事情都是可以的。



这是我现在得到的错误代码:


 失败:生成失败并出现异常。 




  • 出错:执行失败,执行失败:transformClassesWithJarMergingForDebug '。


    com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:
    / android / support / annotation / WorkerThread.class


  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。



这里是项目等级文件:

 任务包装(类型:Wrapper){
gradleVersion ='2.2'

buildscript {
repositories {
mavenCentral()
jcenter()
}
依赖关系{
classpath'com.android .tools.build:gradle:2.1.0'
classpath'com.google.gms:google-services:2.1.0'

}



apply plugin:'com.android.application'
allprojects {
repositories {
jcenter()
flatDir {
dirs'libs'


$ b编译fileTree(dir:'libs',include:['* .jar'])
compile(名称:'aescrypt-0.0.1',ext:'aar')
编译项目(':viewmover-1.1.0(1)')
编译项目(':fab-1.1.2' )
c (':uitools-1.1.0')
compile('com.android.support:appcompat-v7: 23.4.0'){
exclude group:'com.google.android',module:'support-v4'
}
compile'c​​om.android.support:design:23.4.0 '
compile'c​​om.google.code.gson:gson:2.6.2'
compile'c​​om.github.paolorotolo:appintro:3.4.0'


compile('com.google.android.gms:play-services-gcm:8.1.0'){
exclude group:'com.google.android',module:'support-v4'


}
}


android {
compileSdkVersion 23
buildToolsVersion '23 .0.1'

configurations {
all * .exclude module:'annotation'
}
defaultConfig {
applicationIdco.goldentime
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 23
}
来源集{
main {
manifest.srcFile'AndroidManifest.xml'
java.srcDirs = ['submodules / linphone / mediastreamer2 / java / src','submodules / linphone / java / j2se' ,'submodules / linphone / java / common','submodules / linphone / java / impl','submodules / externals / axmlrpc / src / main / java','submodules / linphone / coreapi / help / java','src' ]
resources.srcDirs = ['submodules / linphone / mediastreamer2 / java / src','submodules / linphone / java / j2se','submodules / linphone / java / common','submodules / linphone / java / impl ','submodules / externals / axmlrpc / src / main / java','submodules / linphone / coreapi / help / java','src']
aidl.srcDirs = ['submodules / linphone / mediastreamer2 / java / src','submodules / linphone / java / j2se','submodules / linphone / java / common','submodules / linphone / java / impl','submodules / externals / axmlrpc / src / main / java','submodules / linphone / coreapi / help / java','src']
renderscript.srcDirs = ['submodules / linphone / mediastreamer2 / java / src','submodules / linphone / java / j2se','submodules / linphone / java / common','submodules / linphone / java / impl' ,'submodules / externals / axmlrpc / src / main / java','submodules / linphone / coreapi / help / java','src']
res.srcDirs = ['res']
assets。 srcDirs = ['assets']
jniLibs.srcDir'libs'

java.exclude'** / mediastream / MediastreamerActivity.java'
}

//将测试移动到tests / java,tests / res等...
instrumentTest.setRoot('tests')

//将构建类型移动到构建类型/ <类型>
//例如,build-types / debug / java,build-types / debug / AndroidManifest.xml,...
//将它们移出它们在src /< type>下的默认位置; / ...
//与主源集合使用的src /有冲突。
//添加新的构建类型或产品风格应该伴随
//通过类似的定制。
debug.setRoot('build-types / debug')
release.setRoot('build-types / release')
}


}
apply plugin:'com.google.gms.google-services'

我发现不同版本的support-v4存在问题,但我不知道应该排除哪一个。我在 libs 中有一个android-support-v4.jar。



请告知我是否需要其他信息。



谢谢。

解决方案

您应该添加

  compile'c​​om。 android.support:support-v4:23.0.1'

删除




  • module:'support-v4'


  • android-support-v4.jar

  • >

    然后 Clean-Rebuild-Sync &运行你的项目。希望这有助于


    I have update my android studio and SDK and some package dependencies on grade of the project and since then I have faced with a lot of problem that I think the reason is incompatibility between dependencies.

    As I researched I found that many people have same problems and it is not rare. I have solved some of the error but problems just appears one after another and I am just confused. hope you can help me find out the problem and its solution.

    Code works well on new android versions ! (a little strange) and I can compile and run the app on android 21+. but when I try to run it on below 21 android version it give me an error. Every thing was ok before I migrate to Android studio 2.

    Here is the error code I get now :

    FAILURE: Build failed with an exception.
    

    • What went wrong: Execution failed for task ':transformClassesWithJarMergingForDebug'.

      com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/WorkerThread.class

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    here is the project grade file :

    task wrapper(type: Wrapper) {
        gradleVersion = '2.2'
    }
    buildscript {
        repositories {
            mavenCentral()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.1.0'
            classpath 'com.google.gms:google-services:2.1.0'
    
        }
    
    
    }
    apply plugin: 'com.android.application'
    allprojects {
        repositories {
            jcenter()
            flatDir {
                dirs 'libs'
            }
        }
    }
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile(name: 'aescrypt-0.0.1', ext: 'aar')
        compile project(':viewmover-1.1.0 (1)')
        compile project(':fab-1.1.2')
        compile files('libs/slf4j-api-1.7.18.jar')
        compile project(':uitools-1.1.0')
        compile('com.android.support:appcompat-v7:23.4.0') {
            exclude group: 'com.google.android', module: 'support-v4'
        }
        compile 'com.android.support:design:23.4.0'
        compile 'com.google.code.gson:gson:2.6.2'
        compile 'com.github.paolorotolo:appintro:3.4.0'
    
    
        compile ('com.google.android.gms:play-services-gcm:8.1.0')   {
            exclude group: 'com.google.android', module: 'support-v4'
    
    
        }
    }
    
    
    android {
        compileSdkVersion 23
        buildToolsVersion '23.0.1'
    
        configurations{
            all*.exclude module: 'annotation'
        }
        defaultConfig {
            applicationId "co.goldentime"
            multiDexEnabled true
            minSdkVersion 16
            targetSdkVersion 23
        }
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['submodules/linphone/mediastreamer2/java/src', 'submodules/linphone/java/j2se', 'submodules/linphone/java/common', 'submodules/linphone/java/impl', 'submodules/externals/axmlrpc/src/main/java', 'submodules/linphone/coreapi/help/java', 'src']
                resources.srcDirs = ['submodules/linphone/mediastreamer2/java/src', 'submodules/linphone/java/j2se', 'submodules/linphone/java/common', 'submodules/linphone/java/impl', 'submodules/externals/axmlrpc/src/main/java', 'submodules/linphone/coreapi/help/java', 'src']
                aidl.srcDirs = ['submodules/linphone/mediastreamer2/java/src', 'submodules/linphone/java/j2se', 'submodules/linphone/java/common', 'submodules/linphone/java/impl', 'submodules/externals/axmlrpc/src/main/java', 'submodules/linphone/coreapi/help/java', 'src']
                renderscript.srcDirs = ['submodules/linphone/mediastreamer2/java/src', 'submodules/linphone/java/j2se', 'submodules/linphone/java/common', 'submodules/linphone/java/impl', 'submodules/externals/axmlrpc/src/main/java', 'submodules/linphone/coreapi/help/java', 'src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
                jniLibs.srcDir 'libs'
    
                java.exclude '**/mediastream/MediastreamerActivity.java'
            }
    
            // Move the tests to tests/java, tests/res, etc...
            instrumentTest.setRoot('tests')
    
            // Move the build types to build-types/<type>
            // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
            // This moves them out of them default location under src/<type>/... which would
            // conflict with src/ being used by the main source set.
            // Adding new build types or product flavors should be accompanied
            // by a similar customization.
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
    
    
    }
    apply plugin: 'com.google.gms.google-services'
    

    I find out there is problem with different version of support-v4 but I do not know which one should be exclude. I have a "android-support-v4.jar" in the libs.

    let me know if it is needed some other information.

    thank you.

    解决方案

    You should add

    compile 'com.android.support:support-v4:23.0.1'
    

    And remove

    • module: 'support-v4'

    • android-support-v4.jar

    Then Clean-Rebuild-Sync & Run your Project .Hope this helps

    这篇关于Android项目构建成功,但运行失败,出现错误:java.util.zip.ZipException:重复条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆