android - java.util.zip.ZipException:重复项:n.class

标签 android exception gradle runtime-error

  apply plugin: 'com.android.application'
android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "[ MY PACKAGE ]"
        minSdkVersion 15
        targetSdkVersion 24
        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'
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }


}
android {
    useLibrary 'org.apache.http.legacy'
}

repositories {
    jcenter()
    maven {
        url "https://jitpack.io"
    }
}

dependencies {
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpclient:4.5'
    compile 'com.github.deano2390:android-viewbadger:1.0.0'
    compile('com.jakewharton:butterknife:8.6.0') {
        exclude module: 'support-compat'
    }
    compile project(':Library_MobilePaymentSDK')
    testCompile 'junit:junit:4.12'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.github.aakira:expandable-layout:1.4.2@aar'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.google.android.gms:play-services:10.0.0'
    compile 'com.google.firebase:firebase-messaging:10.0.0'
    compile 'com.google.firebase:firebase-core:10.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.android.support.test.espresso:espresso-core:2.2.2'
    compile 'rongi.rotate-layout:rotate-layout:2.0.0'
    compile 'com.roomorama:caldroid:3.0.1'
    compile 'com.maksim88:PasswordEditText:v0.9'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'gun0912.ted:tedpermission:1.0.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.jcmore2.appcrash:appcrash:1.1.0'
    compile 'com.github.stfalcon:smsverifycatcher:0.2'
    compile 'com.github.javiersantos:BottomDialogs:1.2.1'
    testCompile 'junit:junit:4.12'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
    compile files('libs/mpaysdk-sandbox-1.0.28.jar')
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'

此gradle文件在api 21中有效,但是当我在api 19上运行时,发生以下错误。
发生以下错误:

错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: n.class



请帮助我解决这个问题。

最佳答案

解决方案#1:

在终端中,您可以在根项目文件夹中执行以下命令:

./gradlew clean



解决方案#2:

如果您使用的是Android Studio,则可以轻松实现,请转到菜单

Build/Clean Project



它将更新旧的依赖项

解决方案#3:

您可以将以下部分添加到build.gradle文件中:
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

关于android - java.util.zip.ZipException:重复项:n.class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50585381/

相关文章:

java - Firebase 数据库查询返回错误结果

android - 无法从 Moto 360 读取心率传感器 - Android Wear

android - onPostExecute 从未在 android 中调用过

Java反射ClassNotFoundException

python - 我应该在哪里检查状态/抛出异常?

c# - ReadAllLines() 函数是否内置了 try-catch?

android - Unity 项目作为 Gradle 中的依赖项

java - 梯度配置错误

java - 使用离线 gradle 运行标准 java 项目时出现 Android Studio 错误

groovy - 构造/销毁自定义Gradle任务