Home » Android » android – cloud_firestore and firebase_auth compatiblity issue in Flutter

android – cloud_firestore and firebase_auth compatiblity issue in Flutter

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am developing a Flutter app. My app works fine with cloud_firestore and firebase_auth packages when I use them separately. However, when I include both of them together in my pubspecs.yaml file, the build fails and the following message is shown:

Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.7.4/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.5.18/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.5.18/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.2.5/android/src/main/java/io/flutter/plugins/firebase/core/FirebaseCorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’.

    java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Here are the depenencies that I have in my pubspec.yaml file:

dependencies:
   flutter:
     sdk: flutter
   firebase_auth: ^0.5.18
   cloud_firestore: ^0.7.4

I checked the version of packages and they both seem to be at the latest version.

Any help on resolving this issue would be appreciated!

This might be connected to this issue, but I am not sure.

How to&Answers:

Update your gradle version. I was facing the same issue,i have solved it by using below steps.

Step 1:
in app/build.gradle

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

  defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ****multiDexEnabled true****

    }

Step 2:
change gradle version dependencies in android/build.gradle

classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:3.2.0' 

Step 3:
latest version of firebase_auth and cloud_firestore in pubspec.ymal

 cloud_firestore: ^0.12.5+1
  firebase_auth: ^0.11.1+6
  google_sign_in: ^4.0.2

Answer:

For me work just change the minSDKVersion to 23 in the app build.gradle.

Answer:

You need to follow this setup:

Open android/app/build.gradle and add at the bottom of the file:

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

and in the android/build.gradle add the following:

buildscript {
  repositories {
    // ,,,
  }
  dependencies {
    // ...
    classpath 'com.google.gms:google-services:3.2.1' 
   }
 }

Answer:

Use only this dependencies in android/build.gradle and remove any other dependencies

classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'

You have to use this versions in pubspec.yaml

firebase_auth: 0.5.11
google_sign_in: 3.0.4
cloud_firestore: 0.7.3  

Because these versions have updated gradle tooling.

Answer:

Following update should resolve the issue:

Update android/gradle/wrapper/gradle-wrapper.properties

to distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

and update the dependencies and versions

in android/build.gradle

to dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.2'

and android/build.gradle yet

buildscript {
    ext.kotlin_version = '1.3.61'

in pubspec.yaml

firebase_core: ^0.4.2+1 
  cloud_firestore: ^0.12.11