Reputation: 154
We are currently using flutter to develop an app that receives push notifications. Everything worked fine until we did the last Flutter update and now we get a Fatal Exception inside Firebase - FlutterFirebaseMessagingService on Android only.
I couldn't find anything about this on the flutter git so it might be an android problem.
This happens the moment when the app gets a new Notification using Firebase functions and Firebase Messaging. 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; in class 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)
Does anyone already have experience with this error or has an idea how to solve it ?
Edit: 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
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
}
Upvotes: 4
Views: 4705
Reputation: 76649
the error message hints for iid
; the instance ID service. this might be provided by 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:
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
also the library is outdated (possibly might require 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):
implementation 'com.google.firebase:firebase-messaging:17.3.3'
once targeting API level 28, it is also suggested to setup a notification channel:
<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.
remark: the invalid JSON syntax might (most likely) come from posting it wrongfully - otherwise other platforms would not function either; 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.
Upvotes: 3