android - Gradle构建时,任务 ':app:transformClassesWithDexForDebug'执行失败

标签 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'' finished with non-zero exit value 1



我进行了搜索,找到了许多解决方案,但是在我的情况下,这些解决方案都无法正常工作。请在下面找到我的应用程序build.gradle和库build.gradle文件

应用程序级别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天。请帮我解决这个问题。

谢谢,
拉詹

最佳答案

尝试改变

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

}


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

}

关于android - Gradle构建时,任务 ':app:transformClassesWithDexForDebug'执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34427024/

相关文章:

Android studio Gradle 构建从 eclipse 导入

android - JodaTime - 如何将 ISO 8601 时间字符串解析为 DateTime?

Android: RelativeLayout inside FrameLayout, width height 错误

scala - 无法从 Gradle 解析 ScalaTest

android - 如何使用 Kotlin 同时定位 JVM/Native 和 Android

gradle - 将嵌套的额外属性从.gradle迁移到.gradle.kts(DSL)

java - 我无法在 ADT BUNDLE 中找到自定义 html 文件的正确路径

android - 录制视频时摩托罗拉 DROID RAZR 的相机问题

android studio 3.0 停留在 "building gradle project info"

安卓工作室 : Add jar as library?