在Android Studio中构建APK期间执行失败

时间:2017-03-01 11:29:03

标签: android android-studio debugging build

我想在Android Studio中构建一个APk。如果我正常运行项目(运行/运行应用程序),没有问题,我得到BUILD-SUCCESSFUL(有一些错误)。但是,当我想通过运行/构建APK构建APK时,不幸的是我遇到了BUILD-FAILED并出现以下错误:

  

错误:任务':app:transformClassesWithJarMergingForDebug'执行失败。   com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / sun / activation / registries / LineTokenizer.class

这是我的傻瓜:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId 'com.exp.Artoosh'
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 3
        versionName "0.4.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    packagingOptions {
        exclude 'META-INF/mimetypes.default'
        exclude 'META-INF/mailcap.default'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:multidex:1.0.1'
    androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
    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.google.android.gms:play-services-appindexing:9.8.0'
    compile  'org.apache.commons:commons-lang3:3.0'
    compile 'javax.mail:mail:1.4.7'
    compile 'com.sun.mail:android-activation:1.5.6' 
    testCompile 'junit:junit:4.12'
}

你能帮助我并告诉我一个解决方案吗?

2 个答案:

答案 0 :(得分:1)

我解决了。 问题是我一起使用了javax.mail和com.sun.mail。第一个属于java,第二个属于Android。我删除了javax.mail并添加了com.sun.mail,如下所示:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:multidex:1.0.0'
    androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
    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.google.android.gms:play-services-appindexing:9.8.0'
    compile  'org.apache.commons:commons-lang3:3.0'
    compile 'com.sun.mail:android-mail:1.5.6'
    compile 'com.sun.mail:android-activation:1.5.6'

    testCompile 'junit:junit:4.12'
}

答案 1 :(得分:0)

在终端中运行

./gradlew clean

运行构建/清理项目