Commit b432af51 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Don't crash when ADB exits with non-zero exit code (#9653)

parent 36052e68
...@@ -238,14 +238,20 @@ class AndroidDevice extends Device { ...@@ -238,14 +238,20 @@ class AndroidDevice extends Device {
return false; return false;
final Status status = logger.startProgress('Installing ${apk.apkPath}...', expectSlowOperation: true); final Status status = logger.startProgress('Installing ${apk.apkPath}...', expectSlowOperation: true);
final RunResult installResult = await runCheckedAsync(adbCommandForDevice(<String>['install', '-r', apk.apkPath])); final RunResult installResult = await runAsync(adbCommandForDevice(<String>['install', '-r', apk.apkPath]));
status.stop(); status.stop();
// Some versions of adb exit with exit code 0 even on failure :(
// Parsing the output to check for failures.
final RegExp failureExp = new RegExp(r'^Failure.*$', multiLine: true); final RegExp failureExp = new RegExp(r'^Failure.*$', multiLine: true);
final String failure = failureExp.stringMatch(installResult.stdout); final String failure = failureExp.stringMatch(installResult.stdout);
if (failure != null) { if (failure != null) {
printError('Package install error: $failure'); printError('Package install error: $failure');
return false; return false;
} }
if (installResult.exitCode != 0) {
printError('Error: ADB exited with exit code ${installResult.exitCode}');
return false;
}
await runCheckedAsync(adbCommandForDevice(<String>[ await runCheckedAsync(adbCommandForDevice(<String>[
'shell', 'echo', '-n', _getSourceSha1(app), '>', _getDeviceSha1Path(app) 'shell', 'echo', '-n', _getSourceSha1(app), '>', _getDeviceSha1Path(app)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment