Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase_messaging] Unable to use FlutterFirebaseMessagingService.setPluginRegistrant #3757

Closed
ahmaducg opened this issue Oct 4, 2020 · 5 comments · Fixed by #4012
Closed
Labels
type: bug Something isn't working

Comments

@ahmaducg
Copy link

ahmaducg commented Oct 4, 2020

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService

class App : FlutterApplication(), PluginRegistrantCallback {

    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry?) {
        FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
    }
}

Flutter Doctor :

[√] Flutter (Channel stable, 1.22.0, on Microsoft Windows [Version 10.0.19041.508], locale en-GB)
    • Flutter version 1.22.0 at C:\Programming\flutter
    • Framework revision d408d302e2 (5 days ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0


[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Programming\Android_SDK
    • Platform android-30, build-tools 30.0.2
    • ANDROID_SDK_ROOT = C:\Programming\Android_SDK
    • Java binary at: C:\Programming\Android_Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[!] VS Code, 64-bit edition (version 1.49.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • SM G973F (mobile)           • RF8M41ABZFZ   • android-arm64 • Android 10 (API 29)
    • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86   • Android 11 (API 30) (emulator)

! Doctor found issues in 2 categories.

image

@ahmaducg ahmaducg added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 4, 2020
@TahaTesser TahaTesser removed the Needs Attention This issue needs maintainer attention. label Oct 6, 2020
@TahaTesser
Copy link

Hi @ahmaducg
Please use the following code in your project

MainActivity.kt

import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
import io.flutter.view.FlutterMain

class MainActivity : FlutterActivity(), PluginRegistry.PluginRegistrantCallback {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
        FlutterMain.startInitialization(this)
    }

    override fun registerWith(registry: PluginRegistry?) {
        if (!registry!!.hasPlugin("io.flutter.plugins.firebasemessaging")) {
            FirebaseMessagingPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
        }
    }

}

Application.kt

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin
import io.flutter.view.FlutterMain
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService

class Application : FlutterApplication(), PluginRegistrantCallback {

    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
        FlutterMain.startInitialization(this)
    }

    override fun registerWith(registry: PluginRegistry?) {
        if (!registry!!.hasPlugin("io.flutter.plugins.firebasemessaging")) {
            FirebaseMessagingPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
        }
    }
}

Closing as duplicate of #2311

@bsr203
Copy link

bsr203 commented Oct 6, 2020

@TahaTesser I get error for setPluginRegistrant on the line FlutterFirebaseMessagingService.setPluginRegistrant(this) with the code you gave above with firebase-messaging:20.3.0. It goes away with older ver 20.1.6. Is there any change in recent version which cause exactly same message as in the image above

Cannot access 'com.google.firebase.messaging.zzf' which is a supertype of 'io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService'. Check your module classpath for missing or conflicting dependencies

so, I think this is unrelated to the linked issue.

@TahaTesser
Copy link

TahaTesser commented Oct 7, 2020

Hi @ahmaducg
Using the native code from #3757 (comment) has no issues

  firebase_core: ^0.5.0+1
  firebase_messaging: ^7.0.3
dependencies {
    def multidex_version = "2.0.1"
    implementation "androidx.multidex:multidex:$multidex_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.6.0'
    implementation 'com.google.firebase:firebase-messaging:20.3.0'
}
apply plugin: 'com.google.gms.google-services'

        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'
logs
event sent after app closed: {id: 0, progressId: null, message: Running "flutter pub get" in firebase_messaging_example...}
event sent after app closed: {id: 0, progressId: null, finished: true}
Launching lib/main.dart on RMX2001 in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
E/FlutterFcmService(32210): Fatal: failed to find callback
Connecting to VM Service at ws://127.0.0.1:63468/DhJiBElM6kw=/ws
I/evercode.triag(32210): ProcessProfilingInfo new_methods=2868 is saved saved_to_disk=1 resolve_classes_delay=5000
I/flutter (32210): Push Messaging token: dyLKzawfTcaSXkUZTA4pgf:APA91bHEwDyXBZtINTnULn3UHMQBqXa04LdjWs_nmsDVdnpJQ8knUGZkiTaxCIEe81AyNhamJrvQLT1SFNb4KHJiDz8FFpNSmvkRgFTQdsQ13fnS1Ln4m3IXLZDWaKZa6RrqA3z9abTn
V/PhoneWindow(32210): DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@d116a53, this = DecorView@ca07524[MainActivity]
D/ColorExSystemServiceHelper(32210): checkColorExSystemService className = com.google.android.gms.measurement.service.MeasurementBrokerService
D/Surface (32210): Surface::connect(this=0x79425dc000,api=1)
D/mali_winsys(32210): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/Surface (32210): Surface::setBufferCount(this=0x79425dc000,bufferCount=4)
I/SurfaceView(32210): 178556039 visibleChanged:true -> SurfaceHolder.Callback.surfaceCreated
D/Surface (32210): Surface::connect(this=0x79425de000,api=1)
D/mali_winsys(32210): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/ViewRootImpl(32210): setSurfaceViewCreated, created:true
I/SurfaceView(32210): 178556039 surfaceChanged -- format=4 w=1080 h=2400 visibleChanged:true -> SurfaceHolder.Callback.surfaceChanged
D/SurfaceView(32210): updateScreenMode w:1080 h:2400 ViewRoot w:1080 h:2400
D/SurfaceView(32210): try to resquest 60Hz
D/ViewRootImpl(32210): set screen refresh mode 1 due to SurfaceView-178556039
D/SurfaceView(32210): updateScreenMode w:1080 h:2400 ViewRoot w:1080 h:2400
D/SurfaceView(32210): try to resquest 60Hz
W/Gralloc3(32210): mapper 3.x is not supported
E/gralloc (32210): Arm Module v1.0
E/ion     (32210): ioctl c0044901 failed with code -1: Invalid argument
W/gralloc (32210): WARNING: internal format modifier bits not mutually exclusive. AFBC basic bit is always set, so extended AFBC support bits must always be checked.
I/Choreographer(32210): Skipped 1 frames!  The application may be doing too much work on its main thread.
I/SurfaceView(32210): 178556039 visibleChanged:true -> SurfaceHolder.Callback.surfaceDestroyed
D/Surface (32210): Surface::disconnect(this=0x79425de000,api=1)
D/ViewRootImpl(32210): setSurfaceViewCreated, created:false
D/Surface (32210): Surface::disconnect(this=0x79425de000,api=-1)
D/SurfaceView(32210): updateScreenMode w:0 h:0 ViewRoot w:1080 h:2400
D/SurfaceView(32210): try to resquest 90Hz
D/ViewRootImpl(32210): set screen refresh mode 0 due to SurfaceView-178556039
I/Choreographer(32210): Skipped 4 frames!  The application may be doing too much work on its main thread.
I/GED     (32210): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 27, oppidx_max 27, oppidx_min 0
D/ColorExSystemServiceHelper(32210): checkColorExSystemService className = com.google.android.gms.measurement.service.MeasurementBrokerService
D/Surface (32210): Surface::disconnect(this=0x79425dc000,api=1)
V/PhoneWindow(32210): DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@d116a53, this = DecorView@ca07524[MainActivity]
V/PhoneWindow(32210): DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@d116a53, this = DecorView@ca07524[MainActivity]
D/Surface (32210): Surface::connect(this=0x79425dd000,api=1)
D/mali_winsys(32210): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/Surface (32210): Surface::setBufferCount(this=0x79425dd000,bufferCount=4)
D/ColorExSystemServiceHelper(32210): checkColorExSystemService className = com.google.android.gms.measurement.service.MeasurementBrokerService
I/SurfaceView(32210): 178556039 visibleChanged:true -> SurfaceHolder.Callback.surfaceCreated
D/Surface (32210): Surface::connect(this=0x793b21a000,api=1)
D/mali_winsys(32210): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/ViewRootImpl(32210): setSurfaceViewCreated, created:true
I/SurfaceView(32210): 178556039 surfaceChanged -- format=4 w=1080 h=2400 visibleChanged:true -> SurfaceHolder.Callback.surfaceChanged
D/SurfaceView(32210): updateScreenMode w:1080 h:2400 ViewRoot w:1080 h:2400
D/SurfaceView(32210): try to resquest 60Hz
D/ViewRootImpl(32210): set screen refresh mode 1 due to SurfaceView-178556039
D/SurfaceView(32210): updateScreenMode w:1080 h:2400 ViewRoot w:1080 h:2400
D/SurfaceView(32210): try to resquest 60Hz
V/ActivityThread(32210): scheduleReceiver info = ActivityInfo{520d7c 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 = 155951774
W/evercode.triag(32210): Accessing hidden method Landroid/os/WorkSource;->add(I)Z (greylist, reflection, allowed)
W/evercode.triag(32210): Accessing hidden method Landroid/os/WorkSource;->add(ILjava/lang/String;)Z (greylist, reflection, allowed)
W/evercode.triag(32210): Accessing hidden method Landroid/os/WorkSource;->size()I (greylist, reflection, allowed)
W/evercode.triag(32210): Accessing hidden method Landroid/os/WorkSource;->get(I)I (greylist, reflection, allowed)
W/evercode.triag(32210): Accessing hidden method Landroid/os/WorkSource;->getName(I)Ljava/lang/String; (greylist, reflection, allowed)
D/ColorExSystemServiceHelper(32210): checkColorExSystemService className = com.google.android.gms.gcm.PushMessagingRegistrarProxy
I/flutter (32210): onMessage: {notification: {title: this is a title, body: this is a body}, data: {status: done, id: 1, click_action: FLUTTER_NOTIFICATION_CLICK}}
I/SurfaceView(32210): 178556039 visibleChanged:true -> SurfaceHolder.Callback.surfaceDestroyed
D/Surface (32210): Surface::disconnect(this=0x793b21a000,api=1)
D/ViewRootImpl(32210): setSurfaceViewCreated, created:false
D/Surface (32210): Surface::disconnect(this=0x793b21a000,api=-1)
D/SurfaceView(32210): updateScreenMode w:0 h:0 ViewRoot w:1080 h:2400
D/SurfaceView(32210): try to resquest 90Hz
D/ViewRootImpl(32210): set screen refresh mode 0 due to SurfaceView-178556039
I/Choreographer(32210): Skipped 3 frames!  The application may be doing too much work on its main thread.
I/GED     (32210): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 27, oppidx_max 27, oppidx_min 0
D/ColorExSystemServiceHelper(32210): checkColorExSystemService className = com.google.android.gms.measurement.service.MeasurementBrokerService
D/Surface (32210): Surface::disconnect(this=0x79425dd000,api=1)
V/PhoneWindow(32210): DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@d116a53, this = DecorView@ca07524[MainActivity]

flutter_01

This issue is related to providing complete documentation in kotlin #2311

@bsr203
Copy link

bsr203 commented Oct 7, 2020

@TahaTesser Thank you for the time looking into this.
My setup is slightly different and I still see the warning after updating all dependencies to latest. Will explore further.
Could you please post your complete code (github) for the sample?
Thanks. bsr.

@TahaTesser
Copy link

@firebase firebase locked and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants