任务':transformClassesWithJarMergingForDebug'的Android项目错误执行失败 [英] Android Project Error Execution failed for task ':transformClassesWithJarMergingForDebug'

查看:73
本文介绍了任务':transformClassesWithJarMergingForDebug'的Android项目错误执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的android应用程序从eclipse转换为Android Studio.当我构建gradle时,没有任何错误.但是在运行应用程序时,我陷入了以下错误:

I was converting my android application from eclipse to Android Studio. When I built gradle there were no errors. But while running the application I got stuck with the following error:

Error:Execution failed for task ':transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/xmlpull/v1/XmlPullParserException.class

我多次尝试清理/重建项目,但始终遇到相同的错误. 我还尝试了Terminal命令./gradlew来清理它,但是它不起作用.

I tried to clean / rebuild project many times, but I always got the same error. I also tried Terminal command ./gradlew to clean it, but its not working.

Android Studio版本:2.1 摇篮版本:2.1.2 jdk版本:1.8 Android SDK构建工具:24

Android Studio Version:2.1 Gradle Version: 2.1.2 jdk Version: 1.8 Android SDK Build-Tools: 24

build.gradle代码:

build.gradle code:

    apply plugin: 'com.android.application'

dependencies {

    compile ('com.google.android.gms:play-services:9.0.2')
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile files('libs/appcompat_v7.jar')
    compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
    compile files('libs/gcm.jar')
    compile files('libs/android.jar')
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')

    compile ('com.google.android.gms:play-services-analytics:9.0.2')
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/mail.jar')
    compile "com.android.support:support-v4:24.0.0"
    compile "com.android.support:design:24.0.0"
    compile 'com.android.support:multidex:1.0.1'
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary  'org.apache.http.legacy'

    defaultConfig {

        applicationId "com.expedite.apps.vedant"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }


    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

推荐答案

我解决了我的错误:

遵循我的build.gradle代码:

Following my build.gradle code:

    apply plugin: 'com.android.application'

dependencies {
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile('com.google.android.gms:play-services:9.0.2')
    compile ('com.google.android.gms:play-services-analytics:9.0.2')
    compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
    compile "com.android.support:design:24.0.0"
    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/mail.jar')
    compile files('libs/activation.jar')
    compile files('libs/gcm.jar')
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary  'org.apache.http.legacy'

    defaultConfig {

        applicationId "com.expedite.apps.vedant"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    packagingOptions {
        exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
        exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
        exclude 'META-INF/LICENSE-FIREBASE.txt'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

在AndroidManifest.xml中添加这一行 android:name ="android.support.multidex.MultiDexApplication"

Add This one line in AndroidManifest.xml android:name="android.support.multidex.MultiDexApplication"

<application
 .....
 android:name="android.support.multidex.MultiDexApplication">
</application>

这篇关于任务':transformClassesWithJarMergingForDebug'的Android项目错误执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆