Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex' in Android Studio

耗尽温柔 提交于 2019-12-10 18:45:02

问题


I am getting the following error when I run my application where creative sdk is integrated for photo editing option.

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/multidex/MultiDex$V14.class 

This is my apps gradle file.Here creative sdk for image editing option is integrated and multidex option is enabled.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.ileaf.cameraeffects"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            res.srcDirs = ['src/main/res', 'src/main/res/drawable-hdpi', 'src/main/res/drawable-mdpi', 'src/main/res/drawable-xhdpi', 'src/main/res/anim']
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    dexOptions {
//        jumboMode true
        incremental true
        preDexLibraries false
//        javaMaxHeapSize "4g"
    }

}
allprojects {
    apply plugin: 'maven'

    tasks.withType(JavaCompile) {
        options.incremental = true
    }

    repositories {
        mavenCentral()
        jcenter()

        maven {
            url "${project.rootDir}/creativesdk-repo/release"  // The base location of Creative SDK
        }

    }
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'

//        compile 'com.adobe.creativesdk.foundation:assets:0.4.264'
    compile 'com.adobe.creativesdk:image:4.0.0'

    compile 'com.android.support:multidex:1.0.1'
}

and this is my apps Application class.

package com.ileaf.cameraeffects;

import android.support.multidex.MultiDexApplication;

import com.aviary.android.feather.sdk.IAviaryClientCredentials;

public class MyApplication extends MultiDexApplication implements IAviaryClientCredentials {
    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public String getBillingKey() {
        return "";
    }

    @Override
    public String getClientID() {
        return "";
    }

    @Override
    public String getClientSecret() {
        return "";
    }
}

回答1:


Try to remove the explicit dependency on multidex library (remove the compile 'com.android.support:multidex:1.0.1' line from your dependencies in build.gradle).

The gradle plugin adds the correct version automagically when you're specifying multiDexEnabled=true.




回答2:


I removed this line from the dependencies and the multidex problem was solved for me.

compile fileTree(include: ['*.jar'], dir: 'libs')

Then it came to my attention that i already had a multidex jar file in my libs folder.I removed it and included back this line in dependencies and it worked.



来源:https://stackoverflow.com/questions/32043646/errorexecution-failed-for-task-apppackagealldebugclassesformultidex-in-andr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!