If I want to use another plugin that starts in isolate and auto register plugins(like foreground service), there is an issue.
The problem is that flt_worker requires an activity and crashes on registration, which leads to registering only the plugins that was before it in the GeneratedPluginRegistrant
The problem is here :
final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
channel.setMethodCallHandler(new FltWorkerPlugin(registrar.activity()));
I have changed it manually on my side to :
try {
final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
channel.setMethodCallHandler(new FltWorkerPlugin(registrar.activity()));
} catch (Exception e) {
Log.e("Error","FltWorkerPlugin.registerWith", e );
}
And now can see the crash in the logs, but is handled and GeneratedPluginRegistrant can continue with the other plugins. Also I don't use flt_worker from other isolates and above approach is saving me
Btw, I haven't checked if your plugin really needs an activity? If not you can pass a context only. Bellow code does not log a crash when is started from another isolate and also works when I tested it in my app
public static void registerWith(Registrar registrar) {
try {
final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
channel.setMethodCallHandler(new FltWorkerPlugin(registrar.context()));
} catch (Exception e) {
Log.e("Error","FltWorkerPlugin.registerWith", e );
}
}
If I want to use another plugin that starts in isolate and auto register plugins(like foreground service), there is an issue. The problem is that flt_worker requires an activity and crashes on registration, which leads to registering only the plugins that was before it in the GeneratedPluginRegistrant The problem is here :
I have changed it manually on my side to :
And now can see the crash in the logs, but is handled and GeneratedPluginRegistrant can continue with the other plugins. Also I don't use flt_worker from other isolates and above approach is saving me
Btw, I haven't checked if your plugin really needs an activity? If not you can pass a context only. Bellow code does not log a crash when is started from another isolate and also works when I tested it in my app