任务':app:dexDebug'的执行失败

时间:2015-08-19 09:36:57

标签: android google-api android-gradle

这是gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 22
buildToolsVersion "21.0.2"

defaultConfig {
    applicationId "com.cogintus"
    minSdkVersion 17
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}

sourceSets.main {
    jniLibs.srcDir 'src/main/jni'
    jni.srcDirs = [] //disable automatic ndk-build call
}


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

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.gms:google-services:1.3.0-beta1'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v13:20.0.0'
compile 'com.google.apis:google-api-services-youtube:v3-rev120-1.19.0'
compile 'com.google.http-client:google-http-client-android:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.api-client:google-api-client-gson:+'
compile 'com.google.code.gson:gson:2.2.4'
}

当我调试项目时,总会出现此错误:

enter image description here

任务'执行失败':app:dexDebug' 我搜索了错误,我发现依赖项中可能存在冗余编译。 但我试图删除一些但没有结果,如果你知道如何解决这个问题,或者你知道要删除什么帮助我。

2 个答案:

答案 0 :(得分:1)

使用此compile 'com.google.android.gms:play-services:7.5.0'代替compile 'com.google.android.gms:play-services:+'

当您的项目中出现重复的库然后显示此错误时,最后

 dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.gms:google-services:1.3.0-beta1'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:support-v13:20.0.0'
compile 'com.google.apis:google-api-services-youtube:v3-rev120-1.19.0'
compile 'com.google.http-client:google-http-client-android:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.api-client:google-api-client-gson:+'
compile 'com.google.code.gson:gson:2.2.4'
}

答案 1 :(得分:0)

您正在尝试两次编译Play服务库。删除其中一行:

compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services:+'

修改

您还必须删除此行

compile 'com.google.gms:google-services:1.3.0-beta1'

添加以确保你在项目的gradle中有这一行:

classpath 'com.google.gms:google-services:1.3.0-beta1'

一切都在这里:https://developers.google.com/app-invites/android/guides/app