0

So, there is a few question like this but they are old and all suggest to update firebase-firestore depedencie to 18.0.2 but here in Nov 2019, I already using 23.3.0.

I have migrated to AndroidX and other firebase plugins like firebase_auth are working fine. Version cloud_firestore: ^0.12.10+2 (latest)

Error:

E/MethodChannel#plugins.flutter.io/cloud_firestore( 9204):  at android.app.ActivityThread.main(ActivityThread.java:7165)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 9204):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 9204):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
E/MethodChannel#plugins.flutter.io/cloud_firestore( 9204):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)
E/flutter ( 9204): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Firestore component is not present., null)

build.gradle (app level):

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.ved.medcash"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-firestore:21.3.0'
}
apply plugin: 'com.google.gms.google-services'

code:

FirebaseAuth auth = FirebaseAuth.instance;

authSucess() async {
    QuerySnapshot checkData = await server
        .collection('user')
        .where('number', isEqualTo: phoneNumber)
        .getDocuments();

    if (checkData.documents == null || checkData.documents.isEmpty) {

      Navigator.of(context).push(
          MaterialPageRoute(builder: (BuildContext context) => Profile()));
      server.collection('user').add({'number': phoneNumber});
    } else {
      Navigator.of(context).push(
          MaterialPageRoute(builder: (BuildContext context) => MyHomePage()));
    }
  }
Raj Dhakad
  • 852
  • 2
  • 17
  • 39

1 Answers1

0

duplicate for this question

try to exclude

group: 'com.google.guava', module: 'guava-jdk5'

like this

buildscript {
    repositories {
            google()
            jcenter()
        }

    dependencies {
            classpath 'com.android.tools.build:gradle:3.3.0'
            classpath ('com.google.gms:google-services:3.2.1') {
                exclude group: 'com.google.guava', module: 'guava-jdk5'
       }
    }
}

for more explanation show link added above as duplicate

Mahmoud Abu Alheja
  • 3,343
  • 2
  • 24
  • 41