Multiple dex files define Lcom/google/android/gms/internal/zzau

前端 未结 14 1131
[愿得一人]
[愿得一人] 2020-11-29 10:55

I get the error com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzau; when i run my app The gradle files are

ap

相关标签:
14条回答
  • 2020-11-29 11:33

    If anyone else comes across this issue in Ionic removing and re-adding the platform worked for me:

    > ionic cordova rm platform android
    > ionic cordova add platform android
    
    0 讨论(0)
  • 2020-11-29 11:34

    Had the same issue while integrating firebase. For my case, it was caused by version mismatch.

    on the app gradle, i had:

    ext {
        PLAY_SERVICES_VERSION = '10.2.0'
    }
    dependencies {
        compile "com.google.android.gms:play-services-maps:$PLAY_SERVICES_VERSION"
        compile "com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"
        compile "com.google.android.gms:play-services-places:$PLAY_SERVICES_VERSION"
        compile 'com.google.firebase:firebase-database:10.0.1'
    }
    

    the firebase dependancy was added through the integrated firebase plugin in Android studio. When i matched the versions, it worked.

    0 讨论(0)
  • 2020-11-29 11:36

    I was having this issue and none of the solutions worked. What worked for me was adding this plugin

     cordova plugin add cordova-android-play-services-gradle-release --save
    

    and then in both /platforms/android/cordova-plugin-fcm/ and /platforms/android/cordova-plugin-open/ replace

    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
    

    with:

    ext.postBuildExtras = {
      apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
    }
    
    0 讨论(0)
  • 2020-11-29 11:39

    I had similar problem and your question helped me solve mine and probably will help you solve yours. Problem is that you have defined:

    dependencies {
    ...
      compile 'com.google.android.gms:play-services-cast:7.5.0'
    }
    

    and

    dependencies {
    ...
      compile 'com.google.android.gms:play-services:7.0.+'
    ...
    }
    

    Since google services 7.5.0, if you're using single modules from play services you can't use whole play services as dependency simultaneously. Solution is to select only those services that you need instead of whole package e.g.:

    instead of

    dependencies {
    ...
      compile 'com.google.android.gms:play-services:7.0.+'
    ...
    }
    

    use

    dependencies {
    ...
      compile 'com.google.android.gms:play-services-maps:7.0.+'
      compile 'com.google.android.gms:play-services-location:7.0.+'
      compile 'com.google.android.gms:play-services-gcm:7.0.+'
    ...
    }
    

    Also I'm not sure but probably it would be good idea to use the same version of google services in both gradle configs.

    0 讨论(0)
  • 2020-11-29 11:39

    If this is happening with react-native-device-info, you can only change from:

    compile(project(':react-native-device-info'))
    

    to

    compile(project(':react-native-device-info')) {
      exclude group: 'com.google.android.gms'
    }
    

    As described here: https://github.com/rebeccahughes/react-native-device-info/blob/81b0c20fab8a10ccf0341dbd6710d7a5915b06a6/README.md#troubleshooting

    0 讨论(0)
  • 2020-11-29 11:39

    My project is a cordova ionic1 project, I spent a full night and morning to solve this issue, this is what I did beacuse i was having firebase dependencies and google services: Go to this file : platforms\android\cordova-plugin-firebase\cordova-plugin-firebase\app-build.gradle

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            // classpath 'com.google.gms:google-services:3.0.0'
            // i changed the above line from 3.0.0 to 3.1.1
            classpath 'com.google.gms:google-services:3.1.1'
        }
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        compile 'me.leolin:ShortcutBadger:1.1.4@aar'
        //compile 'com.google.firebase:firebase-crash:+'
        // i changed the above line from + to 11.0.2
        compile 'com.google.firebase:firebase-crash:11.0.2'
    }
    

    Then Go to this file: platforms\android\project.properties Originally i was having this

    target=android-26
    android.library.reference.1=CordovaLib
    cordova.gradle.include.1=cordova-plugin-firebase/app-build.gradle
    cordova.system.library.1=com.google.gms:google-services:+
    cordova.system.library.2=com.google.firebase:firebase-core:+
    cordova.system.library.3=com.google.firebase:firebase-messaging:+
    cordova.system.library.4=com.google.firebase:firebase-crash:+
    cordova.system.library.5=com.google.firebase:firebase-config:+
    cordova.system.library.6=com.android.support:support-v4:24.1.1+
    cordova.system.library.7=com.google.android.gms:play-services-auth:11.+
    cordova.system.library.8=com.google.android.gms:play-services-identity:11.+
    

    Then i commented out the google services as we need specific dependencies and I also put the versions for firebase and gms to the same version number of 11.0.2 so after my file looks like this

    target=android-26
    android.library.reference.1=CordovaLib
    cordova.gradle.include.1=cordova-plugin-firebase/app-build.gradle
    # cordova.system.library.1=com.google.gms:google-services:+
    cordova.system.library.2=com.google.firebase:firebase-core:11.0.2
    cordova.system.library.3=com.google.firebase:firebase-messaging:11.0.2
    cordova.system.library.4=com.google.firebase:firebase-crash:11.0.2
    cordova.system.library.5=com.google.firebase:firebase-config:11.0.2
    cordova.system.library.6=com.android.support:support-v4:24.1.1+
    cordova.system.library.7=com.google.android.gms:play-services-auth:11.0.2
    cordova.system.library.8=com.google.android.gms:play-services-identity:11.0.2
    
    0 讨论(0)
提交回复
热议问题