fluttercommunity / flutter_workmanager

A Flutter plugin which allows you to execute code in the background on Android and iOS.
859 stars 276 forks source link

Type mismatch: inferred type is PluginRegistry? but FlutterEngine was expected #130

Closed billyurs closed 4 years ago

billyurs commented 4 years ago

I have followed same instruction for platform setup, but my stacktrace looks like this:

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

My Kotlin file is

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)
    }
}
yase-hesham commented 4 years ago

same problem , have u found any solution ?

mohamadlounnas commented 4 years ago

same

timrijckaert commented 4 years ago

Hey all sorry for the wait,

We identified this is due to a breaking change in Flutter v12.0 in how Flutter plugins are registered with the new Android v2 embedding. See:

We are in the process of preparing a fix for this

Keep you posted.

timrijckaert commented 4 years ago

A new version of WorkManager (0.2.0) is now available on pub.dev. Could you guys try and see if it works?

Thanks in advance.

timrijckaert commented 4 years ago

Can you post the complete stacktrace? We don't use the PackageManager so I'm wondering if this is something flutter_workmanager related. Do you experience this too with the sample app?