diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index 508901835c..e020d2f79e 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -640,8 +640,20 @@ class _AdbLogReader extends DeviceLogReader { // Start the adb logcat process. List args = ['logcat', '-v', 'tag']; String lastTimestamp = device.lastLogcatTimestamp; - if (lastTimestamp != null) - args.addAll(['-T', lastTimestamp]); + if (lastTimestamp != null) { + bool supportsLastTimestamp = false; + + // Check to see if this copy of adb supports -T. + try { + // "logcat: invalid option -- T", "Unrecognized Option" + // logcat -g will finish immediately; it will print an error to stdout if -T isn't supported. + String result = runSync(device.adbCommandForDevice(['logcat', '-g', '-T', lastTimestamp])); + supportsLastTimestamp = !result.contains('logcat: invalid option') && !result.contains('Unrecognized Option'); + } catch (_) { } + + if (supportsLastTimestamp) + args.addAll(['-T', lastTimestamp]); + } runCommand(device.adbCommandForDevice(args)).then((Process process) { _process = process; _process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);