【发布时间】:2020-05-15 06:26:09
【问题描述】:
我想将此字段添加到我的项目中,但出现错误。 https://pub.dev/packages/firebase_messaging#optionally-handle-background-messages
我想在我的应用程序中使用 Firebase 通知。我为此添加了 Aplication.java。添加此文件后,注册表一词带有红色下划线。
GeneratedPluginRegistrant.registerWith(registry);
错误:
\live_chat\android\app\src\main\java\com\**PACKAGENAME**\**APPNAME**\Application.java:18: error: incompatible types: PluginRegistry cannot be converted to FlutterEngine
GeneratedPluginRegistrant.registerWith(registry);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 3s
Finished with error: Gradle task assembleDebug failed with exit code 1
APPNAME/android/app/src/main/java/app-organization-path/Application.java:
package **PACKAGENAME**;
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;
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
@Override
public void registerWith(PluginRegistry registry) {
GeneratedPluginRegistrant.registerWith(registry);
}
}
【问题讨论】:
标签: android firebase flutter notifications firebase-cloud-messaging