Check the adb install output for errors and stop "flutter run" if package installation fails (#3672)

This commit is contained in:
Jason Simmons
2016-05-02 14:11:40 -07:00
parent 5460e94488
commit 30d8dc1399
2 changed files with 17 additions and 7 deletions

View File

@@ -181,7 +181,14 @@ class AndroidDevice extends Device {
if (!_checkForSupportedAdbVersion() || !_checkForSupportedAndroidVersion())
return false;
runCheckedSync(adbCommandForDevice(<String>['install', '-r', app.localPath]));
String installOut = runCheckedSync(adbCommandForDevice(<String>['install', '-r', app.localPath]));
RegExp failureExp = new RegExp(r'^Failure.*$', multiLine: true);
String failure = failureExp.stringMatch(installOut);
if (failure != null) {
printError('Package install error: $failure');
return false;
}
runCheckedSync(adbCommandForDevice(<String>['shell', 'echo', '-n', _getSourceSha1(app), '>', _getDeviceSha1Path(app)]));
return true;
}

View File

@@ -199,11 +199,12 @@ Future<int> startApp(
// Allow any stop commands from above to start work.
await new Future<Duration>.delayed(Duration.ZERO);
if (install) {
// TODO(devoncarew): This fails for ios devices - we haven't built yet.
if (install && device is AndroidDevice) {
printStatus('Installing $package to $device...');
// TODO(devoncarew): This fails for ios devices - we haven't built yet.
await installApp(device, package);
if (!(await installApp(device, package)))
return 1;
}
Map<String, dynamic> platformArgs = <String, dynamic>{};
@@ -290,10 +291,12 @@ Future<int> startAppStayResident(
// Allow any stop commands from above to start work.
await new Future<Duration>.delayed(Duration.ZERO);
printTrace('Running install command.');
// TODO(devoncarew): This fails for ios devices - we haven't built yet.
await installApp(device, package);
if (device is AndroidDevice) {
printTrace('Running install command.');
if (!(await installApp(device, package)))
return 1;
}
Map<String, dynamic> platformArgs;
if (traceStartup != null)