gpt4 book ai didi

flutter - 类型不匹配 : inferred type is PluginRegistry? 但预期 FlutterEngine

转载 作者:行者123 更新时间:2023-12-03 13:29:39 26 4
gpt4 key购买 nike

我想使用 Flutter Workmanager,我在我的 .kt 中做了这样的引用配置:

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"
但它给了我这个错误:

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? butFlutterEngine was expected

FAILURE: Build failed with an exception. * What went wrong:Execution failed for task ':app:compileDebugKotlin'. Compilationerror. See log for more 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

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


有人可以帮帮我吗?

最佳答案

您可以通过替换 application.kt 中的以下方法来解决此问题

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

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

关于flutter - 类型不匹配 : inferred type is PluginRegistry? 但预期 FlutterEngine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59437284/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com