[flutter_tools] Fix crash on null Android apiVersion (#50029)

This commit is contained in:
Zachary Anderson
2020-02-03 14:48:02 -08:00
committed by GitHub
parent abf4e1617d
commit ef62d53222
2 changed files with 71 additions and 46 deletions

View File

@@ -1040,7 +1040,11 @@ class _AdbLogReader extends DeviceLogReader {
];
// logcat -T is not supported on Android releases before Lollipop.
const int kLollipopVersionCode = 21;
final int apiVersion = int.tryParse(await device._apiVersion);
final int apiVersion = (String v) {
// If the API version string isn't found, conservatively assume that the
// version is less recent than the one we're looking for.
return v == null ? kLollipopVersionCode - 1 : int.tryParse(v);
}(await device._apiVersion);
if (apiVersion != null && apiVersion >= kLollipopVersionCode) {
args.addAll(<String>[
'-T',