Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
Crash on beta/3.14.0-0.1.pre with this stacktrace:
_TypeError: type 'Null' is not a subtype of type 'IOSApp' of 'package'
at IOSSimulator.startApp(simulators.dart:471)
at FlutterDriverService.start(drive_service.dart:178)
at <asynchronous gap>(async)
at DriveCommand.runCommand(drive.dart:270)
at <asynchronous gap>(async)
at FlutterCommand.run.<anonymous closure>(flutter_command.dart:1323)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at CommandRunner.runCommand(command_runner.dart:212)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand.<anonymous closure>(flutter_command_runner.dart:339)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand(flutter_command_runner.dart:285)
at <asynchronous gap>(async)
at run.<anonymous closure>.<anonymous closure>(runner.dart:115)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at main(executable.dart:90)
at <asynchronous gap>(async)
Steps to recreate:
flutter create --platforms=macos driver_crash- Add
flutter_driverunderdev_dependenciesin pubspec.yaml
dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
- Add
driver_crash/test_driver/main_test.dartwith the following code
import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:driver_crash/main.dart';
void main() {
enableFlutterDriverExtension();
runApp(const MyApp());
}- Open an iOS simulator and have no other devices attached
- Run
flutter drive
Notes
This is occurring because flutter drive does not consider the project when it selects the device. The project from the steps I listed only supports macOS, however, it'll use the iOS simulator when it runs flutter drive.
You can also recreate this issue by targeting a device that the project doesn't have a platform for.
I don't think this is iOS specific, I believe it would happen for other device types like Android too.
Actual results
Running the above steps will result in a crash
_TypeError: type 'Null' is not a subtype of type 'IOSApp' of 'package'
#0 IOSSimulator.startApp (package:flutter_tools/src/ios/simulators.dart:471:12)
#1 FlutterDriverService.start (package:flutter_tools/src/drive/drive_service.dart:178:29)
<asynchronous suspension>
#2 DriveCommand.runCommand (package:flutter_tools/src/commands/drive.dart:270:9)
<asynchronous suspension>
#3 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1323:27)
<asynchronous suspension>
#4 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#5 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:348:9)
<asynchronous suspension>
#7 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#8 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:294:5)
<asynchronous suspension>
#9 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:113:9)
<asynchronous suspension>
#10 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#11 main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>
Couple of solutions here:
-
We filter the list of selectable device by what platforms are supported by the project, which could hypothetically lead to it throwing an error about no device being found.
-
We add a check to flutter drive that checks if the selected device is supported by the project and if not, throw an error like "You're trying to use flutter drive with a device with a platform type of XXX, however your project does not support that platform blah blah blah"
Logs
Logs
<!-- Paste your logs here -->
Flutter Doctor output
Doctor output
[!] Flutter (Channel master, 3.14.0-14.0.pre.72, on macOS 13.5.1 22G90 darwin-arm64, locale en)
• Flutter version 3.14.0-14.0.pre.72 on channel master at xxx
• Framework revision eb77b525c2 (4 days ago), 2023-09-01 10:43:24 -0400
• Engine revision 4c085b883d
• Dart version 3.2.0 (build 3.2.0-128.0.dev)
• DevTools version 2.27.0
• If those were intentional, you can disregard the above warnings; however it is recommended to use
"git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at xxx
• Platform android-33, build-tools 33.0.0
• ANDROID_SDK_ROOT = xxx
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
• Xcode at /Applications/Beta/beta_8/Xcode.app/Contents/Developer
• Build 15A5229m
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
[✓] VS Code (version 1.81.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.70.0
[✓] Connected device (3 available)
[✓] Network resources
• All expected network resources are available.
Activity
[-]flutter drive crash on when targeting device with unsupported platform[/-][+]flutter drive crashes when targeting device with unsupported platform[/+]christopherfujino commentedon Sep 6, 2023
I agree. I'll just add, another problem here is that we use
covariantinDevice.startApp(), which means this is a runtime error instead of a compile time one: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/device.dart#L748Merge upstream/master and simplify issue flutter#134073 fix
[flutter_tools] Simplify drive device filtering and tests
Merge upstream/master (c60d44a) into investigation/issue-134073
Merge upstream/master (4dfbad3) into investigation/issue-134073
[flutter_tools] Merge master, handle --use-existing-app, and simplify…