错误:Android Studio

时间:2015-08-17 05:58:58

标签: android android-support-library aviary multidex adobecreativesdk

运行我的应用程序时出现以下错误,其中集成了创意sdk用于照片编辑选项。

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

这是我的应用程序gradle文件。集成了用于图像编辑的创意sdk选项,并启用了multidex选项。

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'
}

这是我的应用程序类。

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 "";
    }
}

2 个答案:

答案 0 :(得分:1)

尝试删除对multidex库的显式依赖(从build.gradle中的依赖项中删除compile 'com.android.support:multidex:1.0.1'行)。

当您指定multiDexEnabled=true时,gradle插件会自动添加正确的版本。

答案 1 :(得分:0)

我从依赖项中删除了这一行,并为我解决了multidex问题。

编译fileTree(包括:['* .jar'],dir:'libs')

然后我注意到我的libs文件夹中已经有了一个multidex jar文件。我删除了它,并在依赖项中包含了这一行,并且它有效。