I have added flutter into the existing android app.using prewarm flutter engine.
var flutterEngine = FlutterEngineCache.getInstance().get(Constants.FLUTTER_ENGINE)
if (flutterEngine == null) {
flutterEngine = FlutterEngine(this)
FlutterEngineCache.getInstance().put(Constants.FLUTTER_ENGINE, flutterEngine)
flutterEngine.navigationChannel.setInitialRoute(
"route1"
)
flutterEngine.dartExecutor.executeDartEntrypoint(
DartExecutor.DartEntrypoint.createDefault()
)
}
When I destroying the flutter engine FlutterEngineCache.getInstance().get(Constants.FLUTTER_ENGINE)?.destroy()
I am getting the following error.
java.lang.RuntimeException: Unable to destroy activity: java.lang.RuntimeException: Cannot execute operation because FlutterJNI is not attached to native.
Caused by: java.lang.RuntimeException: Cannot execute operation because FlutterJNI is not attached to native.
at io.flutter.embedding.engine.FlutterJNI.ensureAttachedToNative(FlutterJNI.java:222)
at io.flutter.embedding.engine.FlutterJNI.onSurfaceDestroyed(FlutterJNI.java:315)
at io.flutter.embedding.engine.renderer.FlutterRenderer.stopRenderingToSurface(FlutterRenderer.java:207)
at io.flutter.embedding.android.FlutterView.detachFromFlutterEngine(FlutterView.java:795)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onDestroyView(FlutterActivityAndFragmentDelegate.java:442)
at