Fix hot reload / restart after the back button dismisses the app on Android (#9455)

- [x] Refresh FlutterViews before issuing a hot reload / restart

Fixes #7248
diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart
index fc79f4f..314c60e 100644
--- a/packages/flutter_tools/lib/src/run_hot.dart
+++ b/packages/flutter_tools/lib/src/run_hot.dart
@@ -324,6 +324,8 @@
   }
 
   Future<OperationResult> _restartFromSources() async {
+    printTrace('Refreshing active FlutterViews before restarting.');
+    await refreshViews();
     final Stopwatch restartTimer = new Stopwatch();
     restartTimer.start();
     final bool updatedDevFS = await _updateDevFS();
@@ -409,6 +411,8 @@
   }
 
   Future<OperationResult> _reloadSources({ bool pause: false }) async {
+    printTrace('Refreshing active FlutterViews before reloading.');
+    await refreshViews();
     if (currentView.uiIsolate == null)
       throw 'Application isolate not found';
     // The initial launch is from a script snapshot. When we reload from source
diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart
index 58d3aa7..4028445 100644
--- a/packages/flutter_tools/lib/src/vmservice.dart
+++ b/packages/flutter_tools/lib/src/vmservice.dart
@@ -756,6 +756,7 @@
   }
 
   Future<Null> refreshViews() async {
+    _viewCache.clear();
     await vmService.vm.invokeRpc('_flutter.listViews', timeout: kLongRequestTimeout);
   }