类型不匹配:推断的类型是PluginRegistry?但是FlutterEngine是预期的 [英] Type mismatch: inferred type is PluginRegistry? but FlutterEngine was expected

查看:133
本文介绍了类型不匹配:推断的类型是PluginRegistry?但是FlutterEngine是预期的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想与Flutter Workmanager合作,我在.kt中做了引用的配置,如下所示:

I want to work with Flutter Workmanager, I did the cited configuration in my .kt like this:

package com.example.mybackprocess

import be.tramckrijte.workmanager.WorkmanagerPlugin
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.GeneratedPluginRegistrant

class App : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        WorkmanagerPlugin.setPluginRegistrantCallback(this)
    }

    override fun registerWith(reg: PluginRegistry?) {
        GeneratedPluginRegistrant.registerWith(reg)
    }
}

,并且我已将 android:name 更改为

android:name=".App"

但是它给了我这个错误:

but it gives me this error:

在调试模式下在G3212上启动lib \ main.dart ...e:E:\ mybackprocess \ android \ app \ src \ main \ kotlin \ com \ example \ mybackprocess \ MainActivity.kt:(15,48):类型不匹配:推断的类型是PluginRegistry?但预期会使用FlutterEngine

Launching lib\main.dart on G3212 in debug mode... e:E:\mybackprocess\android\app\src\main\kotlin\com\example\mybackprocess\MainActivity.kt: (15, 48): Type mismatch: inferred type is PluginRegistry? but FlutterEngine was expected

失败:生成失败,发生异常.* 什么地方出了错:任务':app:compileDebugKotlin'的执行失败.汇编错误.请参阅日志以获取更多详细信息

FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:compileDebugKotlin'. Compilation error. See log for more details

尝试:使用--stacktrace选项运行以获取堆栈跟踪.与运行--info或--debug选项可获取更多日志输出.与--scan一起运行以获得完整的见解.*在 https://help.gradle.org

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

55s Gradle任务组装失败,调试失败,并显示退出代码1个退出(sigterm)

BUILD FAILED in 55s Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

有人可以帮我吗?

推荐答案

您可以通过在应用程序中替换以下方法来解决此问题.

you can fix the issue by replacing the following method in your application.kt

override fun registerWith(registry: PluginRegistry?) {
    registry?.registrarFor("com.iotecksolutions.background_location_fetch.BackgroundLocationFetchPlugin");
}

注意:用您的插件名称替换 com.iotecksolutions.background_location_fetch.BackgroundLocationFetchPlugin .

Note: Replace com.iotecksolutions.background_location_fetch.BackgroundLocationFetchPlugin with your plugin name.

这篇关于类型不匹配:推断的类型是PluginRegistry?但是FlutterEngine是预期的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆