1

i want to set a background location tracker for that i use the location_background plugin and follow the steps in background location wiki but when i run build task i get this error :

/home/walid/Desktop/covid19/covid19/android/app/src/main/kotlin/com/example/covid19/Application.java:17: error: incompatible types: PluginRegistry cannot be converted to FlutterEngine GeneratedPluginRegistrant.registerWith(registry); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for 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 4m 52s

the Application.java code :

package com.example.app;

import com.lyokone.location.LocationPlugin;
import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.GeneratedPluginRegistrant;


public class Application  extends FlutterApplication implements PluginRegistry.PluginRegistrantCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        LocationPlugin.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        GeneratedPluginRegistrant.registerWith(registry);
    }
}

android SDK 28 Flutter 1.12.13+hotfix.8

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
  • did you try searching the error message? https://stackoverflow.com/questions/59446933/pluginregistry-cannot-be-converted-to-flutterengine – Ryan M Mar 27 '20 at 22:46

1 Answers1

0

I had exactly same problem and just fixed it using following code (firebase_messaging: ^9.1.1)

import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService;
import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin;

public class Application extends FlutterApplication implements PluginRegistrantCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingBackgroundService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        FlutterFirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
    }

}
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210