Android - Gradle - 执行失败任务':app:packageAllDebugClassesForMultiDex'错误

时间:2015-04-17 14:16:00

标签: android android-gradle android-build

我正在尝试在我的Android项目上进行构建清理,当我这样做时,我最终得到了错误: 任务':app:packageAllDebugClassesForMultiDex'的执行失败。 > java.util.zip.ZipException:重复条目:com / j256 / ormlite / dao / BaseDaoImpl $ 1.class 建立失败

这是我的build.gradle文件的当前副本:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.android.engineering"
        minSdkVersion 16
        targetSdkVersion 21
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

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

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'joda-time:joda-time:2.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile files('libs/achartengine-1.1.0.jar')
    compile files('libs/butterknife-5.1.2.jar')
    compile files('libs/com.google.guava_1.6.0.jar')
    compile files('libs/com.springsource.org.junit-4.10.0.jar')
    compile files('libs/commons-collections-3.2.1.jar')
    compile files('libs/dagger-1.1.0.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/opencsv-3.3.jar')
    compile files('libs/ormlite-android-4.6.jar')
    compile files('libs/ormlite-core-4.45.jar')
    compile files('libs/log4j-1.2.16.jar')
    compile files('libs/icepick-2.3.jar')
    compile files('libs/mockito-core-1.9.5.jar')
} 

我在build.gradle文件中试过这个:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.android.engineering"
        minSdkVersion 16
        targetSdkVersion 21
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

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

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'joda-time:joda-time:2.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile files('libs/achartengine-1.1.0.jar')
    compile files('libs/butterknife-5.1.2.jar')
    compile files('libs/com.google.guava_1.6.0.jar')
    compile files('libs/com.springsource.org.junit-4.10.0.jar')
    compile files('libs/commons-collections-3.2.1.jar')
    compile files('libs/dagger-1.1.0.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/opencsv-3.3.jar')
    compile files('libs/ormlite-android-4.6.jar') { 
        exclude group: 'BaseDoaImpl'
    }
    compile files('libs/ormlite-core-4.45.jar')
    compile files('libs/log4j-1.2.16.jar')
    compile files('libs/icepick-2.3.jar')
    compile files('libs/mockito-core-1.9.5.jar')
} 

当我这样做时,我收到以下错误:“找不到Gradle DSL方法:'exclude()' 可能的原因: - 项目“项目名称”可能正在使用不包含该方法的Gradle版本。 - 构建文件可能缺少Gradle插件。

以下是我的Gradle Wrapper文件的当前副本:

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

如何解决此问题?任何帮助将不胜感激!

0 个答案:

没有答案