Execution failed for task ':app:transformClassesWithDexForDebug' while implementing Google sign in for Android

后端 未结 4 667
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 14:26

I\'m trying to implement Google sign in for Android and I\'m following the instructoins via

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

相关标签:
4条回答
  • 2020-11-28 14:59

    Adding

     dexOptions {
            incremental = true;
            preDexLibraries = false
            javaMaxHeapSize "4g" // 2g should be also OK
        }
    

    in with in android in build.gradle works for me.

    0 讨论(0)
  • 2020-11-28 15:00

    Maybe this link helps you. link

    That helped me:

    android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
        }
    }
    
    0 讨论(0)
  • 2020-11-28 15:10

    This problem occurs because of multiple inclusion of dependencies. You are including a dependency that is already specified in your build.gradle file. For example:

    compile 'com.google.android.gms:play-services:9.0.2'
    compile 'com.google.android.gms:play-services-identity:9.0.2'
    

    the above specification of dependency will generate this problem, because play-services includes everything, including play-services-identity, & so, here the same dependency is included for multiple times.

    The recommended option is to only include those dependencies that you actually need. If you need play services location & maps, only include these dependencies as:

    compile 'com.google.android.gms:play-services-location:9.0.2'
    compile 'com.google.android.gms:play-services-maps:9.0.2'
    

    Without including everything with 'com.google.android.gms:play-services:9.0.2'.

    In your specific case, I suspect the conflict is arising between google-services of the top level gradle file and play-services-identity & play-services-plus in the app level gradle file. Using only those services that you specifically need resolving multiple inclusion will resolve your issue.

    In general, you should not use "multiDexEnabled true" if you don't have a strong & legitimate reason. Using it without knowing the actual problem means that you are bypassing a problem. You are allowing multiple overlapping dependencies yielding a potential source of api conflicts & bigger apk size.

    0 讨论(0)
  • 2020-11-28 15:17

    Had the same problem.
    Mine was fixed by setting the JAVA_HOME variable to java 8 jdk

    export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/"   
    
    0 讨论(0)
提交回复
热议问题