任务执行失败':app:transformClassesWithDexForDebug' gradle构建时出错

时间:2015-12-23 01:04:12

标签: android gradle

我正在尝试将一个库添加到android应用程序中。我在项目设置中添加了库作为依赖项。 然后,当我尝试构建项目时,gradle显示以下错误: 错误:任务':app:transformClassesWithDexForDebug'执行失败。

  

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:Process' command' C:\ Program Files \ Java \ jdk1.7.0 \ bin \ java.exe''完成非零退出值1

我搜索了它并找到了很多解决方案,但是没有一个能解决这个问题。请在下面找我的app build.gradle和library build.gradle文件

app level build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.application.package"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    testCompile 'junit:junit:4.12'
    compile project(':library')
}

和库build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "v0.1L"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

另外,在我的项目build.gradle下面找到

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我在这个问题上被困了整整1天。请帮我解决这个问题。

谢谢, 拉詹

1 个答案:

答案 0 :(得分:0)

尝试更改

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

}

dependencies {
    provided fileTree(dir: 'libs', include: ['*.jar'])
    ...

}