0

I am using the very nice flutter_isolate package together with just_audio to play audio sounds (like alarm bells) when the app is backgrounded.

Together these packages are generally working well but the app does sometimes crash. I note, in the the flutter isolate package readme it advises to create a custom plugin registrant class to register other plugins, and provides example code to help.

Therefore, in android/app/src/main/java/io.flutter.plugins I have created a new java file named CustomPluginRegistrant based off the template provided.

package io.flutter.plugins;

public final class CustomPluginRegistrant {
    public static void registerWith(@NonNull FlutterEngine flutterEngine) {
        flutterEngine.getPlugins().add(new com.ryanheise.just_audio.JustAudioPlugin());
    }
}


Also I have created another java file name MainApplication with this code:

package io.flutter.plugins;
import io.flutter.plugins.CustomPluginRegistrant;

public class MainApplication extends FlutterApplication {
    public MainApplication() {
        FlutterIsolatePlugin.setCustomIsolateRegistrant(CustomPluginRegistrant.class);
    }
}


warnings 1

warnings 2

And when I run the app I get this error:

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class io.flutter.plugins.MainApplication, unresolved supertypes: FlutterApplication

I am not experienced in Java and unsure how to fix these errors. Thanks.

Kdon
  • 892
  • 6
  • 19

0 Answers0