From ce822ec8bb15e44de72f5a449c00dedcc21d74e8 Mon Sep 17 00:00:00 2001 From: Andrew Kolos Date: Tue, 30 Apr 2024 10:38:21 -0700 Subject: [PATCH] include exception details in tool exit displayed when adb call fails (#147498) Fixes #125971 --- .../lib/src/android/android_device_discovery.dart | 3 ++- .../android/android_device_discovery_test.dart | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device_discovery.dart b/packages/flutter_tools/lib/src/android/android_device_discovery.dart index 9d2fd5ef998..a250b360946 100644 --- a/packages/flutter_tools/lib/src/android/android_device_discovery.dart +++ b/packages/flutter_tools/lib/src/android/android_device_discovery.dart @@ -74,7 +74,8 @@ class AndroidDevices extends PollingDeviceDiscovery { } on ProcessException catch (exception) { throwToolExit( 'Unable to run "adb", check your Android SDK installation and ' - '$kAndroidHome environment variable: ${exception.executable}', + '$kAndroidHome environment variable: ${exception.executable}\n' + 'Error details: ${exception.message}', ); } final List devices = []; diff --git a/packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart index 2f2135df0ed..86eedc920e2 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart @@ -87,6 +87,7 @@ void main() { const FakeCommand( command: ['adb', 'devices', '-l'], exitCode: 1, + stderr: '' ), ]); final AndroidDevices androidDevices = AndroidDevices( @@ -99,8 +100,15 @@ void main() { userMessages: UserMessages(), ); - expect(androidDevices.pollingGetDevices(), - throwsToolExit(message: RegExp('Unable to run "adb"'))); + expect( + androidDevices.pollingGetDevices(), + throwsToolExit( + message: + 'Unable to run "adb", check your Android SDK installation and ANDROID_HOME environment variable: adb\n' + 'Error details: Process exited abnormally with exit code 1:\n' + '', + ), + ); }); testWithoutContext('AndroidDevices is disabled if feature is disabled', () {