Repository: flutter
Issue: [Android][Add-to-App] Crash on restoring app from background 
Labels: c: crash,platform-android,engine,a: existing-apps,P2,team-android,triaged-android

## Steps to Reproduce
1. create native app
2. create flutter module 
3. attach flutter fragment from native 
4. send app to background
5. enable "Don't keep activities" and "No Background Processes"
6. open app again:
```
java.lang.IllegalStateException: The requested cached FlutterEngine did not exist in the FlutterEngineCache: '/route'

io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine FlutterActivityAndFragmentDelegate.java:240
2io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach FlutterActivityAndFragmentDelegate.java:175
3io.flutter.embedding.android.FlutterFragment.onAttach FlutterFragment.java:777
4androidx.fragment.app.Fragment.performAttach Fragment.java:2954
5androidx.fragment.app.FragmentStateManager.attach FragmentStateManager.java:463
6androidx.fragment.app.FragmentStateManager.moveToExpectedState FragmentStateManager.java:254
7androidx.fragment.app.FragmentStore.moveToExpectedState FragmentStore.java:113
8androidx.fragment.app.FragmentManager.moveToState FragmentManager.java:1374
9androidx.fragment.app.FragmentManager.dispatchStateChange FragmentManager.java:2841
10androidx.fragment.app.FragmentManager.dispatchCreate FragmentManager.java:2773
11androidx.fragment.app.Fragment.restoreChildFragmentState Fragment.java:1935
12androidx.fragment.app.Fragment.onCreate Fragment.java:1911
13androidx.fragment.app.Fragment.performCreate Fragment.java:2981
14androidx.fragment.app.FragmentStateManager.create FragmentStateManager.java:474
15androidx.fragment.app.FragmentStateManager.moveToExpectedState FragmentStateManager.java:257
16androidx.fragment.app.FragmentStore.moveToExpectedState FragmentStore.java:113
17androidx.fragment.app.FragmentManager.moveToState FragmentManager.java:1374
18androidx.fragment.app.FragmentManager.dispatchStateChange FragmentManager.java:2841
19androidx.fragment.app.FragmentManager.dispatchCreate FragmentManager.java:2773
20androidx.fragment.app.Fragment.restoreChildFragmentState Fragment.java:1935
21androidx.fragment.app.Fragment.onCreate Fragment.java:1911
22androidx.navigation.fragment.NavHostFragment.onCreate NavHostFragment.java:169
23androidx.fragment.app.Fragment.performCreate Fragment.java:2981
24androidx.fragment.app.FragmentStateManager.create FragmentStateManager.java:474
25androidx.fragment.app.FragmentStateManager.moveToExpectedState FragmentStateManager.java:257
26androidx.fragment.app.FragmentStore.moveToExpectedState FragmentStore.java:113
27androidx.fragment.app.FragmentManager.moveToState FragmentManager.java:1374
28androidx.fragment.app.FragmentManager.dispatchStateChange FragmentManager.java:2841
29androidx.fragment.app.FragmentManager.dispatchCreate FragmentManager.java:2773
30androidx.fragment.app.Fragment.restoreChildFragmentState Fragment.java:1935
31androidx.fragment.app.Fragment.onCreate Fragment.java:1911
```

I've found a fix: https://stackoverflow.com/questions/64010393/requested-flutter-engine-does-not-exist-in-add-to-app
but it looks like a workaround to create engine before super.OnCreate(). For example in app I have few flutter fragments, and engine been destroyed with the fragment. At the other hand I should keep in mind what fragments with flutter engine is in stack and then recreate all required engines, in other case I'll get a crash. 

```
 Flutter (Channel stable, 3.0.1, on macOS 12.2.1 21D62 darwin-arm, locale en-DE)
    • Flutter version 3.0.1 at /Users/siarheism/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fb57da5f94 (4 weeks ago), 2022-05-19 15:50:29 -0700
    • Engine revision caaafc5604
    • Dart version 2.17.1
    • DevTools version 2.12.2
Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

```