错误:任务执行失败':firstapp:dexDebug'

时间:2016-04-03 15:50:51

标签: android android-studio

我无法编译项目,得到以下错误编译:

  

错误:任务执行失败':firstapp:dexDebug'。   com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java''完成具有非零退出值2

这是build.gradle

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "fsy.firstapp"
    minSdkVersion 18
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"

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

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':WeiboSDK1')
}

这是库的build.gradle:

apply plugin: 'com.android.library'

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

android {
compileSdkVersion 14
buildToolsVersion "23.0.1"

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')
}
}

我该如何编译项目?

1 个答案:

答案 0 :(得分:0)

可能是因为您的项目:WeiboSDK1也在使用可能导致冲突的支持库,因此您可以尝试将其排除在外,

compile project(':WeiboSDK1') {
    exclude group: 'com.android.support', module:'support-v7'
}

尝试删除module:'support-v7'