E/FirebaseInstanceId:绑定到服务失败。颤振安卓

Posted

技术标签:

【中文标题】E/FirebaseInstanceId:绑定到服务失败。颤振安卓【英文标题】:E/FirebaseInstanceId: binding to the service failed. Flutter Android 【发布时间】:2020-08-01 13:51:39 【问题描述】:

我未能在我的 Flutter android 应用中实现 Firebase。 我在 Android Studio 上创建了一个默认的 Flutter 应用,它同时在模拟器和物理设备上运行。 我创建了一个 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.

【问题讨论】:

请添加flutter doctor -v的输出 @MahabubulHasan,我刚刚添加了 请问您是否遇到同样的问题***.com/questions/59605100/… 是的,我尝试了所有给定的解决方案 找到解决方案了吗? 【参考方案1】:

我只是忽略了错误并再次重新启动应用程序。

然后运行我已经实现的测试功能来检查它是否工作,它确实工作。

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

我在代码中实现了它,并且我在数据库中有一个条目。

在调试控制台中,我得到如下输出:

I/flutter (22372):“QuerySnapshot”实例

这意味着它有效。

【讨论】:

以上是关于E/FirebaseInstanceId:绑定到服务失败。颤振安卓的主要内容,如果未能解决你的问题,请参考以下文章

Android 应用程序在模拟器中启动时崩溃

APN 中的 Firebase 令牌生成器失败

如果我关闭活动,从 BroadcastReceiver.onReceive 调用 peekService 将返回 null

fcm 订阅主题

springboot11

文件上传漏洞