在为Android实施Google登录时,任务':app:transformClassesWithDexForDebug'的执行失败

Rag*_*age 13 android gradle android-gradle-plugin google-signin

我正在尝试为Android实施Google登录,而我正在关注instructoins

https://developers.google.com/identity/sign-in/android/start-integrating

但在构建应用程序时,我收到以下错误.

信息:Gradle任务[:app:generateDebugSources,:app:generateDebugAndroidTestSources,:app:assembleDebug]:app:preBuild UP-TO-DATE:app:preDebugBuild UP-TO-DATE:app:checkDebugManifest:app:preReleaseBuild UP-TO-日期:应用:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE:应用:prepareComAndroidSupportDesign2301Library UP-TO-DATE:应用:prepareComAndroidSupportSupportV42301Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesAds810Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesBase810Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesIdentity810Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesPlus810Library UP-TO-DATE :应用:prepareDebugD 依赖:app:compileDebugAidl UP-TO-DATE:app:compileDebugRenderscript UP-TO-DATE:app:generateDebugBuildConfig UP-TO-DATE:app:generateDebugAssets UP-TO-DATE:app:mergeDebugAssets UP-TO-DATE:app:generateDebugResValues最新消息:app:processDebugGoogleServices找不到包名为'com.questo.rugved.questo'的匹配客户端:app:generateDebugResources:app:mergeDebugResources UP-TO-DATE:app:processDebugManifest UP-TO-DATE:app: processDebugResources UP-TO-DATE:app:generateDebugSources UP-TO-DATE:app:preDebugAndroidTestBuild UP-TO-DATE:app:prepareDebugAndroidTestDependencies:app:compileDebugAndroidTestAidl UP-TO-DATE:app:processDebugAndroidTestManifest UP-TO-DATE:app:compileDebugAndroidTestRenderscript最新版本:app:generateDebugAndroidTestBuildConfig UP-TO-DATE:app:generateDebugAndroidTestAssets UP-TO-DATE:app:mergeDebugAndroidTestAssets UP-TO-DATE:app:generateDebugAndroidTestResValues UP-TO-DATE:app:generateDebugAndroidTestResources UP-TO-DATE :应用:mergeDebugAndr oidTestResources UP-TO-DATE:app:processDebugAndroidTestResources UP-TO-DATE:app:generateDebugAndroidTestSources UP-TO-DATE:app:compileDebugJavaWithJavac UP-TO-DATE:app:compileDebugNdk UP-TO-DATE:app:compileDebugSources UP-TO-日期:app:transformClassesAndResourcesWithExtractJarsForDebug:app:transformClassesWithDexForDebug UNEXPECTED TOP-LEVEL EXCEPTION:错误:任务':app:transformClassesWithDexForDebug'的执行失败.com.android.build.transform.api.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'command'/ usr/lib/jvm/java-7-oracle/bin/java''以非零退出值2结束信息:BUILD FAILED信息:总时间:1分钟39.994秒信息:1错误信息:0警告信息:在控制台中查看完整输出

我的顶级gradle是


    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.3.0'
            classpath 'com.google.gms:google-services:1.4.0-beta3'

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

    allprojects {
        repositories {
            jcenter()
        }
    }
    
My app level gradle is

<pre>

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

    android {
        compileSdkVersion 23
        buildToolsVersion '23.0.1'

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

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.0.1'
        compile 'com.android.support:design:23.+'
        compile 'com.google.android.gms:play-services-identity:8.1.0'
        compile 'com.google.android.gms:play-services-plus:8.1.0'
    }
Run Code Online (Sandbox Code Playgroud)

请帮忙.

Alb*_*spo 20

也许这个链接可以帮到你.链接

这帮助了我:

android {
...
defaultConfig {
    ...
    multiDexEnabled true
    }
}
Run Code Online (Sandbox Code Playgroud)


Rea*_*sel 5

发生此问题的原因是依赖项的多个包含。您包括在build.gradle文件中已经指定的依赖项。例如:

compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.android.gms:play-services-identity:9.0.2'
Run Code Online (Sandbox Code Playgroud)

上面的依赖性说明将产生此问题,因为播放服务包括所有内容,包括播放服务身份,等等,因此多次包含相同的依赖性。

推荐的选项是仅包括您实际需要的那些依赖项。如果您需要游戏服务位置和地图,请仅包括以下依赖项:

compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.google.android.gms:play-services-maps:9.0.2'
Run Code Online (Sandbox Code Playgroud)

但不包含“ com.google.android.gms:play-services:9.0.2”中的所有内容。

在您的特定情况下,我怀疑顶级gradle文件的google-services与应用程序级别gradle文件中的play-services-identity&play-services-plus之间发生冲突。仅使用那些您特别需要解决多个包含问题的服务即可解决您的问题。

通常,如果没有充分和合理的理由,则不应使用“ multiDexEnabled true”。在不知道实际问题的情况下使用它意味着您正在绕过问题。您允许多个重叠的依赖项产生潜在的api冲突和更大的apk大小。