Skip to content

Commit ce822ec

Browse files
authored
include exception details in tool exit displayed when adb call fails (flutter#147498)
Fixes flutter#125971
1 parent af27093 commit ce822ec

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/flutter_tools/lib/src/android/android_device_discovery.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class AndroidDevices extends PollingDeviceDiscovery {
7474
} on ProcessException catch (exception) {
7575
throwToolExit(
7676
'Unable to run "adb", check your Android SDK installation and '
77-
'$kAndroidHome environment variable: ${exception.executable}',
77+
'$kAndroidHome environment variable: ${exception.executable}\n'
78+
'Error details: ${exception.message}',
7879
);
7980
}
8081
final List<AndroidDevice> devices = <AndroidDevice>[];

packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void main() {
8787
const FakeCommand(
8888
command: <String>['adb', 'devices', '-l'],
8989
exitCode: 1,
90+
stderr: '<stderr from adb>'
9091
),
9192
]);
9293
final AndroidDevices androidDevices = AndroidDevices(
@@ -99,8 +100,15 @@ void main() {
99100
userMessages: UserMessages(),
100101
);
101102

102-
expect(androidDevices.pollingGetDevices(),
103-
throwsToolExit(message: RegExp('Unable to run "adb"')));
103+
expect(
104+
androidDevices.pollingGetDevices(),
105+
throwsToolExit(
106+
message:
107+
'Unable to run "adb", check your Android SDK installation and ANDROID_HOME environment variable: adb\n'
108+
'Error details: Process exited abnormally with exit code 1:\n'
109+
'<stderr from adb>',
110+
),
111+
);
104112
});
105113

106114
testWithoutContext('AndroidDevices is disabled if feature is disabled', () {

0 commit comments

Comments
 (0)