firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.68k stars 3.97k forks source link

🐛 [firebase_messaging] Inconsistent behavior with background message handler callback on Android. #4017

Closed firatcetiner closed 3 years ago

firatcetiner commented 3 years ago

What happened?

Firebase Cloud Messaging plugin's background message handler doesn't always work correctly. The message raised from Flutter debug console is W/FirebaseInstanceId(17720): Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed.. I get this "error" most of the times. See related issue #2181 and pull request #1774 (which claims to solve this issue). I was doing some sqlite operations with moor_flutter on that method and I completely ignored them for now. Right now the handler method is like this:

  Future<dynamic> _handleBackgroundMessage(Map<String, dynamic> message) async {
    print('message received');
    return Future<void>.value();
  }

And it doesn't event print 'message received'.

Steps to reproduce

Steps to reproduce the behavior:

  1. Use firebase_messaging: 7.0.3,
  2. Send only a data (not notification) message with Firebase Admin SDK (this shouldn't be important at this point),

Plugin Registry

Application.kt

class Application : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry) {
        FirebaseCloudMessagingPluginRegistrant.registerWith(registry);
        SqflitePluginRegistrant.registerWith(registry)
    }
}

FirebaseCloudMessagingPluginRegistrant.kt

object FirebaseCloudMessagingPluginRegistrant {
    fun registerWith(registry: PluginRegistry) {
        if (alreadyRegisteredWith(registry)) {
            return
        }
        FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
    }

    private fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
        val key = FirebaseCloudMessagingPluginRegistrant::class.java.canonicalName
        if (registry.hasPlugin(key)) return true
        registry.registrarFor(key)
        return false
    }
}

flutter doctor -v

[√] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.18362.1139], locale en-US)
    • Flutter version 1.22.2 at C:\Users\asus\Documents\SDK\flutter-stable
    • Framework revision 84f3d28555 (3 weeks ago), 2020-10-15 16:26:19 -0700
    • Engine revision b8752bbfff
    • Dart version 2.10.2

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\asus\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

Flutter dependencies

- animations 1.1.2 [flutter]
- background_fetch 0.6.0 [flutter]
- cached_network_image 2.3.2+1 [flutter flutter_cache_manager octo_image]
- clipboard 0.1.2+8 [flutter]
- collection 1.15.0-nullsafety.3
- connectivity 0.4.9+3 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web]
- crypto 2.1.5 [collection convert typed_data]
- dio 3.0.10 [http_parser path]
- dotted_border 1.0.6 [flutter path_drawing]
- equatable 1.2.5 [collection meta]
- extended_nested_scroll_view 1.0.1 [flutter]
- extended_sliver 1.0.1 [flutter]
- eyro_toast 0.1.0 [flutter]
- firebase_core 0.5.0+1 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_messaging 7.0.3 [meta flutter firebase_core]
- flare_flutter 2.0.6 [flutter flare_dart meta]
- fluentui_icons 0.2.0 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_bloc 6.0.6 [flutter bloc provider]
- flutter_local_notifications 1.4.4+3 [flutter platform flutter_local_notifications_platform_interface]
- flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math]
- flutter_mobx 1.1.0+2 [mobx flutter]
- flutter_secure_storage 3.3.5 [meta flutter]
- flutter_slidable 0.5.7 [flutter]
- flutter_svg 0.19.0 [path_drawing xml vector_math meta flutter]
- get_it 5.0.1 [async meta]
- hive 1.4.4+1 [meta crypto]
- hive_flutter 0.3.1 [flutter hive path_provider path]
- html 0.14.0+4 [csslib source_span]
- image_cropper 1.3.1 [flutter]
- image_picker 0.6.7+11 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- just_audio 0.5.4 [just_audio_platform_interface audio_session rxdart path path_provider async uuid flutter]
- logging 0.11.4
- meta 1.3.0-nullsafety.3
- mobx 1.2.1+3 [meta]
- modal_progress_hud 0.1.3 [flutter]
- moor_flutter 3.1.0 [moor sqflite meta path flutter]
- path_provider 1.6.18 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- provider 4.3.2+2 [flutter nested collection]
- pull_to_refresh 1.6.2 [flutter]
- pull_to_refresh_notification 1.1.2 [flutter]
- rxdart 0.24.1
- share 0.6.5+2 [meta mime flutter]
- signalr_client 0.1.6 [flutter logging w3c_event_source]
- sticky_headers 0.1.8+1 [flutter meta]
- timeago 2.0.27
- uni_links 0.4.0 [flutter]
- url_launcher 5.7.2 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]

dev dependencies:
- build_runner 1.10.2 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_serv
er io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span strea
m_channel string_scanner term_glyph typed_data]
- hive_generator 0.7.3 [build source_gen hive analyzer dartx]
- mobx_codegen 1.1.1+1 [analyzer build build_resolvers meta mobx path source_gen]
- moor_generator 3.3.1 [collection recase meta path json_annotation stream_transform args logging cli_util moor sqlparser analyzer analyzer_plugin source_span build buil
d_resolvers build_config source_gen]
- retrofit_generator 1.4.0 [dio source_gen built_collection code_builder tuple retrofit analyzer dart_style build]

dependency overrides:
- analyzer 0.39.17 [_fe_analyzer_shared args charcode cli_util collection convert crypto glob html meta package_config path pub_semver source_span watcher yaml]

transitive dependencies:
- _fe_analyzer_shared 7.0.0 [meta]
- analyzer_plugin 0.3.0 [analyzer charcode dart_style html meta path pub_semver]
- args 1.6.0
- async 2.5.0-nullsafety.1 [collection]
- audio_session 0.0.9 [flutter flutter_web_plugins rxdart]
- bloc 6.0.3 [meta]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- build 1.3.0 [analyzer async convert crypto logging meta path glob]
- build_config 0.4.2 [checked_yaml json_annotation meta path pubspec_parse yaml]
- build_daemon 2.1.4 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 1.3.11 [analyzer build crypto graphs logging path package_config pub_semver]
- build_runner_core 6.0.1 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pedantic pool
timing watcher yaml]
- built_collection 4.3.2 [collection quiver]
- built_value 7.1.0 [built_collection collection fixnum quiver]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- checked_yaml 1.0.2 [json_annotation source_span yaml]
- cli_util 0.1.4 [path]
- clock 1.1.0-nullsafety.1
- code_builder 3.5.0 [built_collection built_value collection matcher meta]
- connectivity_for_web 0.3.1+2 [connectivity_platform_interface flutter_web_plugins flutter]
- connectivity_macos 0.1.0+5 [flutter]
- connectivity_platform_interface 1.0.6 [flutter meta plugin_platform_interface]
- convert 2.1.1 [charcode typed_data]
- csslib 0.16.2 [source_span]
- dart_style 1.3.6 [analyzer args path source_span]
- dartx 0.5.0 [collection path crypto characters time meta]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase 7.3.0 [http http_parser js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- fixnum 0.10.11
- flare_dart 2.3.4
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 1.4.2 [flutter path_provider uuid http path sqflite pedantic clock file rxdart]
- flutter_local_notifications_platform_interface 1.0.1 [flutter plugin_platform_interface]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- graphs 0.2.0
- http 0.12.2 [http_parser path pedantic]
- http_multi_server 2.2.0 [async]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface]
- intl 0.16.1 [path]
- io 0.3.4 [charcode meta path string_scanner]
- js 0.6.2
- json_annotation 3.1.0
- just_audio_platform_interface 1.1.0 [flutter meta plugin_platform_interface]
- matcher 0.12.10-nullsafety.1 [stack_trace]
- mime 0.9.7
- moor 3.3.1 [meta convert collection synchronized pedantic sqlite3]
- nested 0.0.4 [flutter]
- node_interop 1.1.1 [js]
- node_io 1.1.1 [node_interop path]
- octo_image 0.3.0 [flutter flutter_blurhash]
- package_config 1.9.3 [path charcode]
- path 1.8.0-nullsafety.1
- path_drawing 0.4.1+1 [vector_math meta path_parsing flutter]
- path_parsing 0.1.4 [vector_math meta]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+4 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- pool 1.4.0 [async stack_trace]
- process 3.0.13 [file intl meta path platform]
- pub_semver 1.4.4 [collection]
- pubspec_parse 0.1.5 [checked_yaml json_annotation pub_semver yaml]
- quiver 2.1.3 [matcher meta]
- recase 3.0.0
- retrofit 1.3.4+1 [meta dio]
- shelf 0.7.9 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel]
- sky_engine 0.0.99
- source_gen 0.9.7+1 [analyzer async build dart_style glob meta path pedantic source_span]
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- sqflite 1.3.1+1 [flutter sqflite_common path]
- sqflite_common 1.0.2+1 [synchronized path meta]
- sqlite3 0.1.6 [collection ffi meta]
- sqlparser 0.10.1 [meta collection source_span charcode]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- stream_transform 1.2.0
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- time 1.3.0
- timing 0.1.1+2 [json_annotation]
- tuple 1.0.3 [quiver]
- typed_data 1.3.0-nullsafety.3 [collection]
- url_launcher_linux 0.0.1+1 [flutter]
- url_launcher_macos 0.0.1+8 [flutter]
- url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.4+1 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+1 [flutter]
- uuid 2.2.2 [crypto convert]
- vector_math 2.1.0-nullsafety.3
- w3c_event_source 1.3.2
- watcher 0.9.7+15 [async path pedantic]
- web_socket_channel 1.1.0 [async crypto stream_channel]
- win32 1.7.3 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]
- yaml 2.2.1 [charcode collection string_scanner source_span]
mdalihusain commented 3 years ago

I don't see this file in documentation which you have used - FirebaseCloudMessagingPluginRegistrant.kt . The documentation mentions MainActivity.kt and Appliaction.kt .

Code for MainActivity.kt -

package com.example.yourpackagename

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

Code for Application.kt -

package com.example.yourpackagename

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
class Application : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }
    override fun registerWith(registry: PluginRegistry?) {
        io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
    }
}

Apart from this, you also need to do some changes in the AndroidManifest.xml and app level build.gradle. Assuming that you have done those changes already, I would suggest you to try these changes given above.

Also I would like to know what do you want to do in the background message handler, because even though the background message handler is getting fired consistently in my application but its of no use because I am unable to do anything inside it except from printing some thing in the console.

Seems that the background message handler runs as an isolate - #3520 , I wanted to use Firestore in background but it isn't possible it seems, because FirebaseApp needs to be initialized which is itself not possible in an isolate.

Therefore, I tried to add what I wanted to do in sharedPreferences, so that I could perform those tasks when the app starts in the foreground, but unfortunately, I am unable to access sharedPreferences in the background message handler as well.

Seems like the backgroundMessageHandler is useless for now..

TahaTesser commented 3 years ago

Hi @firatcetiner As mentioned above you need to configure background code properly on the Android side Nevertheless, I tried to reproduce data only payload (Excluding notification on Android)

Paylaod

DATA='{"priority": "high", "data": {"click_action": "FLUTTER_NOTIFICATION_CLICK", "id": "1", "status": "done"}, "to": "dPB1w6TvRnid4pErhW-WCH:APA91bHwrUwt4GqZ13vfpUiz04rRpJuNaTLSYj_a8PvpES1oCg3VWvPOPPTjolIl-A-ZZt95lInRvaygnsCgUEDRsdQv27WV4IswVKawqqABrijS2hum8M1LUncJXnwrFIs54pO7-lEe"}'
curl https://fcm.googleapis.com/fcm/send -H "Content-Type:application/json" -X POST -d "$DATA" -H "Authorization: key=AAAAcVC6H8o:APA91bF9eBcw6f4RbqJ89uYUGJ7RpMm2w0-yU8T8TIJ5LgXbjc91z_WxlOOzsUotZc6kYpqIQs7EnO5Im00xrLNuLpbkZ7VHgtFQ_Jv19W-XMi2dvWLteOZDTo77u8SzPHy-qF1bxBgp"

logs when each payload is sent

V/ActivityThread(16954): scheduleReceiver info = ActivityInfo{e28de0e com.google.firebase.iid.FirebaseInstanceIdReceiver} intent = Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11080010 pkg=com.nevercode.triage cmp=com.nevercode.triage/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) } sync = true hasCode = 210433762
D/ColorExSystemServiceHelper(16954): checkColorExSystemService className = com.google.android.gms.gcm.PushMessagingRegistrarProxy
V/ActivityThread(16954): scheduleReceiver info = ActivityInfo{9d16fc5 com.google.firebase.iid.FirebaseInstanceIdReceiver} intent = Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11080010 pkg=com.nevercode.triage cmp=com.nevercode.triage/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) } sync = true hasCode = 243983015
D/ColorExSystemServiceHelper(16954): checkColorExSystemService className = com.google.android.gms.gcm.PushMessagingRegistrarProxy
firatcetiner commented 3 years ago

As mentioned above you need to configure background code properly on the Android side

@TahaTesser FirebaseCloudMessagingPluginRegistrant.ks already do that. What's the difference between my code and the one above?

Update: I changed my code to match the code above but the same issue appears even in the foreground message handler method, I can't reach any payload. This is very strange.

Ehesp commented 3 years ago

There is a 8.0 dev release out with major reworks to background handling if you want to give the release a try.

firatcetiner commented 3 years ago

@Ehesp Thanks for pointing that out. By 8.0 dev I'm assuming you are referring firebase_messaging (dev) because I already tried that and nothing change.

Dependency

 firebase_messaging:
    git:
      url: git://github.com/FirebaseExtended/flutterfire
      ref: dev
      path: ./packages/firebase_messaging
mdalihusain commented 3 years ago

@firatcetiner is this issue happening on emulator or physical device? If it's happening on a physical device, which device you are using and have you tried another device?

firatcetiner commented 3 years ago

@mdalihusain All tests done on physical devices. I have used Xiaomi Redmi Note 8 Pro (Android 10), Xiaomi Mi 6 (Android 9). Why should I worry about the manufacturer?

mdalihusain commented 3 years ago

@mdalihusain All tests done on physical devices. I have used Xiaomi Redmi Note 8 Pro (Android 10), Xiaomi Mi 6 (Android 9). Should I worry about the manufacturer of device?

It's fine, mine is also Xiaomi Redmi Note 8 Pro (Android 10), and everything is working absolutely fine I asked about the device because I have read on forums that OnePlus strictly forces to stop background processes..

Only two other reasons I can think because of which the issue is occurring -

  1. might be related to the android manifest.xml and build.gradle configuration... Which version of firebase messaging have you used in the dependency in build.gradle? Please upload code of AndroidManifest.xml and build.gradle of possible
  2. Any other flutter plugin is causing issues with Firebase messaging. You should try creating a new project and then try using Firebase messaging.
firatcetiner commented 3 years ago

@mdalihusain Thanks for your help. Here are the files:

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.myapplication">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <application
        android:name=".Application"
        android:icon="@mipmap/ic_launcher"
        tools:replace="android:label"
        android:allowBackup="false"
        android:usesCleartextTraffic="true"
        android:fullBackupContent="false"
        tools:targetApi="m">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2"/>
        <meta-data
            android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
            android:value="true"/>
        <meta-data
            android:name="io.flutter.embedding.android.SplashScreenDrawable"
            android:resource="@drawable/launch_background" />
    </application>
</manifest>

build.gradle (module)

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 {
        applicationId "com.exampe.myapplication"
        minSdkVersion 18
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
        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
        }
    }
    compileOptions {
        sourceCompatibility "1.8"
        targetCompatibility "1.8"
    }
    buildToolsVersion = '29.0.2'
}

flutter {
    source '../..'
}

dependencies {
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    implementation 'com.android.support:multidex:1.0.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

builld.gradle (project)

buildscript {
    ext.kotlin_version = '1.4.10'
    ext {
        compileSdkVersion   = 29                // or higher
        targetSdkVersion    = 29                // or higher
        appCompatVersion    = "1.0.2"           // or higher
    }
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.android.tools.build:gradle:3.6.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "${project(':background_fetch').projectDir}/libs"
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

What's the point of trying this plugin on a new project? I mean we always use other packages/plugins in our projects and it is almost impossible to determine which plugin cause incompatibilities with Firebase Messaging, or vice versa.

mdalihusain commented 3 years ago

The build.gradle and AndroidManifest files seem to be alright...

The point with creating a new application is to make sure that another plugin is causing this issue or the problem is with Firebase messaging itself .

firatcetiner commented 3 years ago

Well if that is the case it means I have to manually check every other plugin separately to see the incompatibilities, which is not ideal for me since I'm using tons of different packages/plugins. Anyway, I will try creating a new project using only Firebase Messaging.

Salakar commented 3 years ago

@Ehesp Thanks for pointing that out. By 8.0 dev I'm assuming you are referring firebase_messaging (dev) because I already tried that and nothing change.

Dependency

 firebase_messaging:
    git:
      url: git://github.com/FirebaseExtended/flutterfire
      ref: dev
      path: ./packages/firebase_messaging

We meant 8.0.0-dev.4 - see the migration guide: https://firebase.flutter.dev/docs/migration

firatcetiner commented 3 years ago

I confirm that firebase_messaging 8.0.0-dev.4 resolves this issue and I'm going to close it, it would be good to have some ideas about when this new rework land on the stable channel. Thank you all for your help

Salakar commented 3 years ago

I confirm that firebase_messaging 8.0.0-dev.4 resolves this issue and I'm going to close it, it would be good to have some ideas about when this new rework land on the stable channel. Thank you all for your help

@firatcetiner 1-2 weeks - providing no major issues reported whilst on dev channel.