0
votes

l am a newbie in Flutter and have followed many different online tutorials but l have been stuck on the same problem(error) for weeks. l keep getting this error every time l connect flutter to firebase_auth and cloud_firestore

Note: C:\Users\HP USER\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\cloud_firestore-1.0.3\android\src\main\java\io\flutter\plugins\firebase\firestore\FlutterFirebaseFirestorePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Users\HP USER\AppData\Local\Pub\Cache\hosted\pub.flutter io.cn\cloud_firestore-1.0.3\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operation Note: Recompile with -Xlint: unchecked for details. Note: C:\Users\HP USER\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\firebase_core-1.0.2\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details. Note: C:\Users\HP USER\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\firebase_auth-1.0.1\android\src\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint: deprecation for details.

My pubspec.yaml looks like this:

name: pakaipa_for_real description: A new Flutter project. publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"

dependencies:
flutter: sdk: flutter

firebase_core: "^1.0.2"
firebase_auth: "^1.0.1"
cloud_firestore: "^1.0.3"

dev_dependencies:
flutter_test: sdk: flutter

flutter:
uses-material-design: true

My app/build.gradle looks like:

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 plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID 
(https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.pakaipa_for_real"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    
    }

    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 {
    implementation 'com.google.firebase:firebase-analytics'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

My android/build.gradle looks like:

buildscript {
ext.kotlin_version = '1.3.50'
repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:4.1.0'
    classpath 'com.google.gms:google-services:4.3.5'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
} 
enter code here

Thanks for the help in advance!

2
Have you tried running pub upgrade and then flutter clean ?Sarvesh Dalvi
Yes l tried but still getting the same errors kataz

2 Answers

0
votes

You need to remove implementation 'com.google.firebase:firebase-analytics' from dependencies in your app/build.gradle

You should add any firebase feature dependencies using pubspec.yaml, if you need analytics in your project more information here: https://pub.dev/packages/firebase_analytics

About have to add firebase to flutter app: https://firebase.google.com/docs/flutter/setup?platform=android

0
votes

In app/build.gradle dependencies, add:

implementation platform('com.google.firebase:firebase-bom:26.4.0')
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-auth'