-
Notifications
You must be signed in to change notification settings - Fork 4k
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] Application.kt: Type mismatch: inferred type is PluginRegistry but FlutterEngine was expected #1684
Comments
+1 same problem here! |
I'm having the same issue with my Application.kt file after upgrading to Flutter v1.12.13 and firebase_message v6.0.9. |
+1 same problem here! |
Hi all, </activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" /> to: </activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="1" /> |
I tried but it doesn't solve. I had to back to activity V1. |
There is a workaround mentioned in: #1613 Replace: override fun registerWith(registry: PluginRegistry?) {
GeneratedPluginRegistrant.registerWith(registry) //Error thrown here
} To: override fun registerWith(registry: PluginRegistry?) {
io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
} Also temporary downgrade firebase_messaging: ^5.1.6 The build crash is solved. Don't know if "background messaging" works. If someone can confirm that? |
I had the same problem in Application.kt: package com.application.customerApplication
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) {
GeneratedPluginRegistrant.registerWith(registry)
}
} To solve the problem I now use in Application.tk: package com.application.customerApplication
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
override fun registerWith(registry: PluginRegistry?) {
registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin");
}
} I found this solution in here. But there are still problems in background notifications, like:
|
Hi @manueldipietro |
Yep, but in this way you cannot manage background message. |
Yes, It works but using previous version of plugin ( <=6.0.6 ). |
Hey, Thank You This Is Work For Me |
any update on this? Same issue with a new project created with:
|
I have been struggling with this issue for the last 4 days. To say that this is a massive issue is an understatement. Its making this plugin in android completely unusable for what I'm doing. The version I've been trying to get working is version 6.0.9. It's the latest version. If you need more information on this issue I'll be happy to provide it to you. Please let me know. It's kind of urgent I get this working. And the trouble is I have other plugins I am using and If I break flutters plugin system to get this plugin working it kind of defeats the benefit. |
it's likely that you deleted the default metadata in AndroidManifest.xml |
@collinjackson @kroikie Any updates, please? This issue blocks new projects receive push notifications from Cloud Messaging. |
It is currently impossible to handle background push notifications (what you need the most basically) on Android because of this problem. When can we expect a fix ? It is not working with latest 6.0.13, also getting the same error. Changing the Push Notification is a very basic feature of any application, I was expecting it to be simple when I switched to Flutter + FCM but it looks like I was wrong... |
I managed to fix the issue. The following are changes I had to make. It took an exhaustive search on the internet to figure this out. I wish the people associated with this project would just fix the docs with the correct information. The other piece of the for this is that when you set your intent you use the URL on the firebase console. NOT the url you encoded. This was one little line on an obscure page in the firebase dock. It took me weeks to find it. Cheers hope this helps. Add the following to the AndroidManifest.xml
FirebaseCloudMessagingPluginRegistrant.kt
MainActivity.kt
Application.kt
|
And this is a bug with the documentation in MYHO making it a bug with the plugin. |
@pneves001 but you still don't get background notifications .. |
No I got it working. But background notifications happen when the app is closed. I also added this to the main.dart file of my app Some of it is in the main function
|
@pneves001 that is weird because in my case background messages work if i set the android embedding to version 1 and switch back to the old kotlin implementation... but with embedding v2 and your new implementation it's only working if the app is in the foreground. |
@pneves001, After doing these workarounds. Do we not use GeneratedPluginRegistrant.java anymore? I have this in the file and I'm not sure what's causing the crash after installation during debugging. There's no error whatsoever on my side.
|
Any update on this? I'm getting the same error as the OP had 4 months ago. |
This comment has been minimized.
This comment has been minimized.
@mnorhamizan This is what I get too. :( Flutter Channel master, 1.18.0-9.0.pre.122 |
@pneves001 Why did you commented out the |
The FlutterApplication() base class already implements the configureFlutterEngine(). So you don't need to do it again. |
Hi @Aurora12 , did you gix the crash on launch? I am having the same issue, can't get around it. |
This comment has been minimized.
This comment has been minimized.
I'd like to second this comment:
The Readme should have instructions for Kotlin since it is the default for new Flutter projects. |
Yes I'm agree |
This comment has been minimized.
This comment has been minimized.
This is what I am still getting:
I still have this same issue, seems like this new set up complicates things... I guess I might have to put off notifications on my app for the time being... are there any known alternatives? |
+1 same problem here! |
Still no Kotlin instructions on the latest |
This is what I have in
|
Based on advice found in #1775, this is what I had for
What is the significance of adding Can you explain why your Finally, why do we need to tweak |
Hello guys, how to configure it to embedding v2? Here I'm having this trouble:
|
I am also getting the same error, Type mismatch: inferred type is PluginRegistry but FlutterEngine was expected tried above all solutions. Nothing worked. Can anyone show me workaround to fix it? I am using following versions, implementation 'com.google.firebase:firebase-messaging:20.2.4' |
Following solution works for me as well, |
It's work for me,
|
solved the problem. I used java, you can also use jeans. MainActivity.kt :
FirebaseCloudMessagingPluginRegistrant.java :
Application.java :
AndroidManifest.xml :
|
What is om.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver? |
Do change in your app-level Gradle : compileSdkVersion 30 |
Hey all 👋 As part of our roadmap (#2582) we've just shipped a complete rework of the If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here. Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin. Thanks everyone. |
For those who have used this solution in the past and upgrade the All you need to do is change your FirebaseCloudMessagingPluginRegistrant.ktpackage com.your.packagename
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin
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: String? = FirebaseCloudMessagingPluginRegistrant::class.java.getCanonicalName()
if (registry.hasPlugin(key)) {
return true
}
registry.registrarFor(key)
return false
}
}
|
Problem
I'm using the master repo version of firebase_messaging and I also done the fix suggested in last README.md.
My environment
• No issues found!
Code:
MainActivity.kt
Application.kt
The text was updated successfully, but these errors were encountered: