How run background process with the work manager in flutter?

风格不统一 提交于 2020-04-16 03:04:31

问题


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

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)
}
}

and I have change android:name to

android:name=".App"

but it gives me this error:

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

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. 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 code 1
Exited (sigterm)

来源:https://stackoverflow.com/questions/59478280/how-run-background-process-with-the-work-manager-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!