android - 重复的 zip 条目 [classes.jar :android/support/v4/media/MediaBrowserCompat$MediaItem$1. 类]

标签 android android-studio gradle build run-app

我的应用构建成功 但是当我尝试在手机上运行它或生成签名的 apk 时,它显示以下错误:

Error:Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [D:\new order\New folder\Cash Rewards Android Studio Project\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Tonu\.gradle\caches\transforms-1\files-1.1\support-media-compat-27.1.1.aar\74c0d7272a41b9a26a44494f0220b268\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/media/MediaBrowserCompat$MediaItem$1.class]))

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
BUILD FAILED in 11s

我的app级build.gradle如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "online.mobilebucks.app"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 101
        versionName "1.0.1"

        multiDexEnabled true


    }

    aaptOptions {
        additionalParameters "--no-version-vectors"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        configurations.all{
            resolutionStrategy.force 'com.android.support:animated-vector-drawable:27.1.1'
            resolutionStrategy.force 'com.android.support:cardview-v7:27.1.1'
            resolutionStrategy.force 'com.android.support:palette-v7:27.1.1'



        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    dexOptions {

        javaMaxHeapSize "4g"
    }
}



//Include Supersonic maven repositories
repositories {
    maven {
        url "https://dl.bintray.com/supersonic/android-sdk"
    }
    maven {
        url "http://dl.bintray.com/supersonic/android-adapters"
    }
    maven { url "https://bitbucket.org/adscend/androidsdk/raw/master/" }


    maven {
        url  "https://adcolony.bintray.com/AdColony"
    }

    flatDir {
        dirs 'libs'
    }

    maven {
        url "https://mymavenrepo.com/repo/dT2TdROtzilvjRTJOVps/"
    }

    maven {
        url "https://dl.bintray.com/ironsource-mobile/android-sdk"
    }
    maven {
        url 'https://dl.bintray.com/personaly/maven'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    // MultiDex Dependency
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.android.support:design:27.1.1'
    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile('org.apache.httpcomponents:httpmime:4.3.6') {
        exclude module: 'httpclient'
    }
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
    //noinspection GradleCompatible
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    compile 'com.google.android.gms:play-services-ads:10.2.1'
    compile 'com.google.android.gms:play-services-auth:10.2.1'
    compile 'com.google.android.gms:play-services-analytics:10.2.1'
    compile 'com.google.android.gms:play-services-basement:10.2.1'
    //compile 'com.google.android.gms:play-services-appindexing:10.2.1'
    compile 'com.intuit.sdp:sdp-android:1.0.3'
    // DatabasePackage
    compile 'com.neovisionaries:nv-websocket-client:2.3'
    compile 'com.percolate:caffeine:0.3.3'
    compile 'com.koushikdutta.async:androidasync:2.2.1'
    compile 'com.google.android.gms:play-services-base:10.2.1'
    compile 'com.percolate:caffeine:0.3.3'
    compile 'com.koushikdutta.async:androidasync:2.2.1'
    compile 'com.supersonic.sdk:mediationsdk:6.4.17@jar'
    compile 'com.adcolony:sdk:3.0.5'
    compile 'com.android.support:support-annotations:25.3.1'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.code.gson:gson:2.6.2'
    compile files('libs/whitemobisdk_1.0.3.jar')
    compile files('libs/revmob.jar')
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.firebase:firebase-messaging:10.2.1'
    compile 'com.google.android.gms:play-services-ads:10.2.1'
    compile 'com.google.code.gson:gson:2.6.2'
    compile files('libs/vungle-publisher-adaptive-id-4.0.2.jar')
    compile files('libs/adscendmedia1.0.1.jar')
    // Adcash SDK:
    compile 'com.adcash:adcash-sdk-lib:2.4.0'
    compile(name: 'OfferToroSdk-v3.1.9', ext: 'aar')
    compile project(':KiwiSDK')
    compile 'com.android.support:recyclerview-v7:27.1.1'
    compile 'com.squareup.okhttp3:okhttp:3.6.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile('com.expletus.rubicko:rubicko:1.0.1@aar') {
        exclude group: 'com.google.code.gson'
        exclude group: 'com.android.volley'
        transitive = true
    }
    compile 'com.ironsource.sdk:mediationsdk:6.7.9@jar'
    compile 'com.startapp:inapp-sdk:3.8.4'
    compile 'com.theoremreach:theoremreach:3.2.7'
    implementation files('libs/AdxmiSdk_v5.7.0_2016-05-06.jar')
    implementation 'com.github.d-max:spots-dialog:0.7@aar'
    compile 'ly.persona.sdk:personaly:1.0.678@aar'
    implementation files('libs/android-support-v4-1.jar')
}
apply plugin: 'com.google.gms.google-services'

我已经搜索过,但没有找到有用的信息。我还尝试使缓存失效。

最佳答案

此问题通常在使用 2 个版本的支持库时发生。在您的 gradle 中更改以下内容。

1)改变

'com.android.support:support-annotations:25.3.1'

'com.android.support:support-annotations:27.1.1'

2)改变

implementation files('libs/android-support-v4-1.jar')

implementation 'com.android.support:support-v4:27.1.1' 

关于android - 重复的 zip 条目 [classes.jar :android/support/v4/media/MediaBrowserCompat$MediaItem$1. 类],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50675060/

相关文章:

android - Activity startActivityForResult 不会触发 onActivityResult

android - 4.1 android 模拟器没有检测到 sd 卡

android - Android Studio 中 make 和 build 的区别

android - Android Studio 4.1 更新后应用程序的 Gradle 构建错误

android - 谷歌 GCM 还可用吗?

android - 如何收听 webview url 单击和启用/禁用操作栏上的按钮

java - Android 中的列表(特别是 RecyclerView 和 CardView)如何工作

AndroidStudio/gradle 找不到 javax.persistence 包

scala - 如何将 build.gradle 导入 IntelliJ

java - 虽然我使用 AsyncTask 但应用程序没有响应