E/FirebaseInstanceId: binding to the service failed. Flutter Android

6,464

I just ignored the error and Restarted the app again.

And ran the test function that I had implemented to check if its working or not, and it did.

floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {
          Firestore.instance
              .collection("...") // Location in your database 
              .snapshots().listen((data) {
                print(data);
              });
        },
      ),

I implemented it in the code and also I had an entry in the database.

In debug console I get output as:

I/flutter (22372): Instance of 'QuerySnapshot'

This means it works.

Share:
6,464
Feruzjon
Author by

Feruzjon

Updated on December 12, 2022

Comments

  • Feruzjon
    Feruzjon over 1 year

    I am failing to implement Firebase to my Flutter Android app.
    I created a default Flutter app on Android Studio and it is running on both emulator and physical device.
    I created a Firebase app and added all the plugins and the dependencies on android/build.gradle and app/build.gradle.
    The google-services.json file is placed in the android/app folder.

    However I got the following message: E/FirebaseInstanceId( 3662): binding to the service failed

    Can anyone help?

    android/build.gradle

    buildscript {
        ext.kotlin_version = '1.3.50'
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.0'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.3.3'
        }
    }
    
    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
    }
    

    app/build.gradle

    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 29
    
        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }
    
        lintOptions {
            disable 'InvalidPackage'
        }
    
        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId "com.israelzadeh.firebasetest"
            minSdkVersion 16
            targetSdkVersion 29
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        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:17.2.2'
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    }
    
    

    flutter doctor -v output

    [√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.778], locale en-GB)
        • Flutter version 1.12.13+hotfix.9 at E:\flutter
        • Framework revision f139b11009 (3 weeks ago), 2020-03-30 13:57:30 -0700
        • Engine revision af51afceb8
        • Dart version 2.7.2
    
    [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
        • Android SDK at C:\Users\comfe\AppData\Local\Android\sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-29, build-tools 29.0.3
        • Java binary at: E:\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
        X Android license status unknown.
          Try re-installing or updating your Android SDK Manager.
          See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.
    
    [√] Android Studio (version 3.6)
        • Android Studio at E:\Android\Android Studio
        • Flutter plugin version 45.1.1
        • Dart plugin version 192.7761
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    
    [!] IntelliJ IDEA Community Edition (version 2019.3)
        • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2.4
        X Flutter plugin not installed; this adds Flutter specific functionality.
        X Dart plugin not installed; this adds Dart specific functionality.
        • For information about installing plugins, see
          https://flutter.dev/intellij-setup/#installing-the-plugins
    
    [√] VS Code (version 1.44.2)
        • VS Code at C:\Users\comfe\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.9.1
    
    [√] Connected device (1 available)
        • ONEPLUS A6013 • 9e2734d0 • android-arm64 • Android 9 (API 28)
    
    ! Doctor found issues in 2 categories.