web-dev-qa-db-ja.com

E / FirebaseInstanceId:サービスへのバインドに失敗しました。フラッターAndroid

Flutter AndroidアプリにFirebaseを実装できません。
デフォルトのFlutterアプリをAndroid Studioに作成し、エミュレーターと物理デバイスの両方で実行しています。
Firebaseアプリを作成し、すべてのプラグインとAndroid/build.gradleおよびapp/build.gradleへの依存関係を追加しました。
google-services.jsonファイルは、Android/appフォルダーに配置されます。

ただし、次のメッセージが表示されました:E/FirebaseInstanceId( 3662): binding to the service failed

誰か助けてもらえますか?

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'
}

フラッタードクター-v出力

[√] 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.

9
Feruzjon

私はエラーを無視し、再起動再びアプリを無視しました。

そして、私が実装したテスト機能を実行して、機能するかどうかを確認しました。

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

私はそれをコードに実装し、データベースにもエントリを入れました。

デバッグコンソールでは、次のように出力されます。

I/flutter(22372):「QuerySnapshot」のインスタンス

これは機能することを意味します。

1
Karan Owalekar