-
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] Type mismatch: inferred type is PluginRegistry? but FlutterEngine was expected #1613
Comments
Fixed by replace with:
|
Hi @Jacobsjj2 |
This does allow me to compile, but I'm not sure if the background service is being registered correctly since I get the error
Doesn't the replacement simply return a |
Try this replace @Jacobsjj2
|
Sorry for the delay! @hsangtini's latest suggestion works. I guess it would also be necessary to update the documentation to that then? |
I tried your solution and i am getting
|
tq work for me |
I also had this problem, I changed the "Application.kt" to the suggested one. and now it's compiling, I just haven't tested the notifications yet. Application.ktpackage br.gov.rj.riodasostras.riodasostrasapp
import android.os.Bundle
import io.flutter.app.FlutterActivity
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
//import com.google.firebase.messaging.FirebaseMessagingService
class Application : FlutterApplication() , PluginRegistrantCallback {
override fun onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
override fun registerWith(registry: PluginRegistry?) {
//GeneratedPluginRegistrant.registerWith(registry);
//registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin");
io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
} MainActivity.ktpackage br.gov.rj.riodasostras.riodasostrasapp
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
flutter doctor flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.1, on Microsoft Windows [versão 10.0.18362.657], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[√] Android Studio (version 3.6)
[√] IntelliJ IDEA Community Edition (version 2019.3)
[√] VS Code (version 1.45.1)
[√] Connected device (1 available)
• No issues found!
PS D:\MyDartProjects\riodasostrasapp> flutter doctor -v
[√] Flutter (Channel stable, 1.20.1, on Microsoft Windows [versão 10.0.18362.657], locale pt-BR)
• Flutter version 1.20.1 at C:\src\flutter
• Framework revision 2ae34518b8 (5 days ago), 2020-08-05 19:53:19 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
• Android SDK at C:\Users\isaque\AppData\Local\Android\sdk
• Platform android-R, build-tools 29.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] IntelliJ IDEA Community Edition (version 2019.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4
• Flutter plugin version 45.0.2
• Dart plugin version 193.6911.31
[√] VS Code (version 1.45.1)
• VS Code at C:\Users\isaque\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.12.2
[√] Connected device (1 available)
• SM J120H (mobile) • 4200b9bf90139200 • android-arm • Android 5.1.1 (API 22)
• No issues found! Ideally, the Readme and documentation should be updated |
|
@insinfo Do you import? both of them?
|
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. |
Following the instructions on pub.dev for handling background messages doesn't compile for Android since the
GeneratedPluginRegistrant.registerWith
method takes aFlutterEngine
object as a parameter. Using thePluginRegistry
provided by the method throws the errorPlease see the below code for reference
To reproduce
Steps to reproduce the behavior:
Expected behavior
Somehow a FlutterEngine object should be passed to the method in order to successfully build for Android
The text was updated successfully, but these errors were encountered: