所以我在大约 4 个月前写了一个 Flutter 应用程序。现在我想做一个小改动,但我无法再编译应用程序,因为 GeneratedPluginRegistrant.registerWith(this) 不再起作用,我没有更改 Kotlin 代码,只是 Dart 代码。
在“此”,在“GeneratedPluginRegistrant.registerWith(本)”显示我这个错误:
Type mismatch.
Required: FlutterEngine!
Found: MainActivity
Run Code Online (Sandbox Code Playgroud)
主活动类:
import android.os.Bundle
import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.view.FlutterMain
class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this) // here is the error: Type mismatch. Required: FlutterEngine! Found: MainActivity
MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result ->
if (call.method == "helloFromNativeCode") {
val greetings = helloFromNativeCode()
result.success(greetings)
}
}
}
private fun helloFromNativeCode(): String { …Run Code Online (Sandbox Code Playgroud)