简体   繁体   English

Firebase 消息传递错误(仅限 Android) - 新推送通知的致命异常

[英]Firebase Messaging Error(Android only) - Fatal Exception on new Push Notification

We are currently using flutter to develop an app that receives push notifications.我们目前正在使用 flutter 开发一个接收推送通知的应用程序。 Everything worked fine until we did the last Flutter update and now we get a Fatal Exception inside Firebase - FlutterFirebaseMessagingService on Android only.一切正常,直到我们进行了最后一次 Flutter 更新,现在我们在 Firebase 中遇到了致命异常 - FlutterFirebaseMessagingService 仅适用于 Android。

I couldn't find anything about this on the flutter git so it might be an android problem.我在 flutter git 上找不到任何关于此的信息,所以它可能是一个 android 问题。

This happens the moment when the app gets a new Notification using Firebase functions and Firebase Messaging.当应用使用 Firebase 函数和 Firebase 消息传递获得新的通知时,就会发生这种情况。 Sample Data we use:我们使用的样本数据:

{
  notification: {
        title: „hello",
        body: „You got a new Message"
    },
    data: {
        click_action: "FLUTTER_NOTIFICATION_CLICK",
        additional: additional, // some integer values
        message: messageText // Same as message body above
    },
    apns: {
        payload: {
            aps: {
                badge: count,
            },
        },
    },
    token: deviceToken //this is a correct device id
}


admin.messaging().send(message)

Full Device Log完整的设备日志

E/AndroidRuntime( 3436): FATAL EXCEPTION: Firebase-FlutterFirebaseMessagingService E/AndroidRuntime( 3436): Process: de.mandarinmedien.jutta, PID: 3436 E/AndroidRuntime( 3436): java.lang.NoSuchMethodError: No static method zzc(Landroid/content/Context;)Lcom/google/firebase/iid/zzz; E/AndroidRuntime(3436):致命异常:Firebase-FlutterFirebaseMessagingService E/AndroidRuntime(3436):进程:de.mandarinmedien.jutta,PID:3436 E/AndroidRuntime(3436):java.lang.NoSuchMethodError:无静态方法/content/Context;)Lcom/google/firebase/iid/zzz; in class Lcom/google/firebase/iid/zzz;在类 Lcom/google/firebase/iid/zzz 中; or its super classes (declaration of 'com.google.firebase.iid.zzz' appears in /data/app/de.mandarinmedien.jutta-gn2RX8mWXXycpVEEEZIaNQ==/base.apk:classes3.dex) E/AndroidRuntime( 3436): at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:110) E/AndroidRuntime( 3436): at com.google.firebase.iid.zzg.run(Unknown Source:4) E/AndroidRuntime( 3436): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) E/AndroidRuntime( 3436): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) E/AndroidRuntime( 3436): at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6) E/AndroidRuntime( 3436): at java.lang.Thread.run(Thread.java:764)或其超类('com.google.firebase.iid.zzz' 的声明出现在 /data/app/de.mandarinmedien.jutta-gn2RX8mWXXycpVEEEZIaNQ==/base.apk:classes3.dex 中)E/AndroidRuntime(3436):在 com.google.firebase.messaging.FirebaseMessagingService.zzd(未知来源:110)E/AndroidRuntime(3436):在 com.google.firebase.iid.zzg.run(未知来源:4)E/AndroidRuntime(3436):在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) E/AndroidRuntime(3436): 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) E/AndroidRuntime(3436):在 com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6) E/AndroidRuntime(3436): 在 java.lang.Thread.run(Thread.java:764)

Does anyone already have experience with this error or has an idea how to solve it ?有没有人已经有过这个错误的经验或知道如何解决它?

Edit: android/app/build.gradle:编辑:android/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.")
}

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

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId ******
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.debug
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.google.firebase:firebase-perf:16.0.0'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'

android/build.gradle android/build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}

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

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex')) {
                details.useVersion "27.1.1"
            }
        }
    }

}

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

the error message hints for iid ; iid的错误消息提示; the instance ID service.实例 ID 服务。 this might be provided by firebase-core ;这可能由firebase-core while it could also be incompatible versions, which occassionaly lead to unknown methods and fields.同时它也可能是不兼容的版本,这偶尔会导致未知的方法和字段。

try to update:尝试更新:

classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.1'

to the current versions:到当前版本:

classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0'

the firebase-perf plugin has to be at the top, not the bottom: firebase-perf插件必须在顶部,而不是底部:

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'

also the library is outdated (possibly might require firebase-core ):该库也已过时(可能需要firebase-core ):

implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-perf:16.1.2'

while I really wonder, why there is no dependency for FCM (as one would expect it):虽然我真的很想知道,为什么FCM没有依赖性(正如人们所期望的那样):

implementation 'com.google.firebase:firebase-messaging:17.3.3'

once targeting API level 28, it is also suggested to setup a notification channel:一旦针对 API 级别 28,还建议设置通知渠道:

<meta-data
    android:name="com.google.firebase.messaging.default_notification_channel_id"
    android:value="@string/default_notification_channel_id" />

... the support libraries would be at version 28.0.0 currently. ...支持库目前的版本为28.0.0

remark: the invalid JSON syntax might (most likely) come from posting it wrongfully - otherwise other platforms would not function either;备注:无效的 JSON 语法可能(很可能)来自错误地发布它 - 否则其他平台也无法运行; I've just added an explanation what is wrong with it and removed the hard-coded values.我刚刚添加了一个解释它有什么问题并删除了硬编码值。 the stack-trace tells a whole other story, not hinting for any invalid syntax.堆栈跟踪讲述了一个完全不同的故事,而不是暗示任何无效的语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Firebase发送推送通知-FATAL EXCEPTION(android) - sending push notification with firebase - FATAL EXCEPTION (android) Firebase 云消息推送通知无法在前台工作,仅在后台工作,在 Android - Firebase Cloud Messaging push notification not working in foreground, only background, on Android Firebase云消息传递Android推送通知不起作用 - firebase cloud messaging Android push notification not working firebase 云消息推送通知 - firebase cloud messaging push notification 无法使用 Firebase 云消息传递向 Android 设备发送推送通知 - Unable to send push notification to android device using firebase cloud messaging Android 12 - 推送通知图标问题(Firebase 消息传递) - Android 12 - Push notification icon problem (Firebase messaging) 使用新sha1的Android Firebase推送通知 - Android Firebase push notification with new sha1 Firebase 云消息传递仅查看 Android 上的最后一条通知 - Firebase Cloud Messaging Only Seeing Last Notification on Android 错误-使用Google Cloud Messaging(GCM)的Android Push Notification - ERROR - Android Push Notification using Google Cloud Messaging (GCM) Android - Firebase 推送通知后端显示错误 - Android - Firebase push notification backend showing error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM