mmcc007 / screenshots

Screenshots: A command line utility and package for capturing screenshots for Flutter
Other
264 stars 144 forks source link

Android emulator cannot be started if Flutter is configured to enable web support. #193

Open alexmarkley opened 4 years ago

alexmarkley commented 4 years ago

Screenshots cannot start an Android emulator if Flutter has been configured to enable web support per these instructions: https://flutter.dev/docs/get-started/web

Output of flutter doctor -v:

[✓] Flutter (Channel beta, v1.17.0-3.2.pre, on Mac OS X 10.15.4 19E287, locale en-US)
    • Flutter version 1.17.0-3.2.pre at /Users/alex/Development/Flutter/flutter
    • Framework revision 2a7bc389f2 (4 days ago), 2020-04-21 20:34:20 -0700
    • Engine revision 4c8c31f591
    • Dart version 2.8.0 (build 2.8.0-dev.20.10)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/alex/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/alex/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.8.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.44.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.9.1

[✓] Connected device (2 available)
    • Chrome     • chrome     • web-javascript • Google Chrome 81.0.4044.122
    • Web Server • web-server • web-javascript • Flutter Tools

• No issues found!

Output of emulator -list-avds:

Pixel_2_API_R

Contents of screenshots.yaml:

tests:
  - test_driver/app.dart
staging: /tmp/screenshots
locales:
  - en-US
frame: false
devices:
  android:
    Pixel 2 API R:

Output of screenshots -v:

[  +52 ms] Starting flutter daemon...
[  +14 ms] executing: flutter daemon
[ +810 ms] <== Starting device daemon...
[   +1 ms] <== [{"event":"daemon.connected","params":{"version":"0.5.3","pid":44171}}]
[   +5 ms] ==> [{"method":"device.enable","id":0}]
[   +1 ms] waiting for response: {method: device.enable, id: 0}
[  +25 ms] <== [{"id":0}]
[  +34 ms] executing: [./] sh -c ios-deploy -c || echo "no attached devices"
[ +185 ms] Starting flutter daemon... (completed in 1.0s)
[   +5 ms] ==> [{"method":"device.getDevices","id":1}]
[        ] waiting for response: {method: device.getDevices, id: 1}
[  +26 ms] <== [{"id":1,"result":[]}]
[   +2 ms] ==> [{"method":"emulator.getEmulators","id":2}]
[        ] waiting for response: {method: emulator.getEmulators, id: 2}
[  +91 ms] <== [{"id":2,"result":[{"id":"Pixel_2_API_R","name":"Pixel 2 API R","category":"mobile","platformType":"android"},{"id":"apple_ios_simulator","name":"iOS Simulator","category":"mobile","platformType":"ios"}]}]
[   +6 ms] daemonEmulator=id: Pixel_2_API_R, name: Pixel 2 API R, category: mobile, platformType: android
[   +4 ms] daemonEmulator=id: apple_ios_simulator, name: iOS Simulator, category: mobile, platformType: ios
[  +93 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/android-wait-for-emulator
[  +39 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/android-wait-for-emulator-to-stop
[  +29 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/simulator-controller
[  +28 ms] executing: [./] chmod u+x /tmp/screenshots/resources/script/sim_orientation.scpt
[  +16 ms] Warning: using default value 'phone' in fastlane directory.
[   +1 ms] Clearing images in android/fastlane/metadata/android/en-US/images/phoneScreenshots for 'Pixel 2 API R'...
[  +30 ms] Starting Pixel 2 API R...
[   +4 ms] ==> [{"method":"emulator.launch","params":{"emulatorId":"Pixel_2_API_R"},"id":3}]
[+3148 ms] <== [{"id":3}]
[ +489 ms] <== [{"event":"device.added","params":{"id":"chrome","name":"Chrome","platform":"web-javascript","emulator":false,"category":"web","platformType":"web","ephemeral":false,"emulatorId":null}}]
Unhandled exception:
Error: emulator Pixel_2_API_R not started: [{"event":"device.added","params":{"id":"chrome","name":"Chrome","platform":"web-javascript","emulator":false,"category":"web","platformType":"web","ephemeral":false,"emulatorId":null}}]
#0      DaemonClient.launchEmulator (package:screenshots/src/daemon_client.dart:86:7)
<asynchronous suspension>
#1      startEmulator (package:screenshots/src/run.dart:434:31)
#2      Screenshots.runTestsOnAll (package:screenshots/src/run.dart:217:21)
#3      Screenshots.run (package:screenshots/src/run.dart:127:11)
<asynchronous suspension>
#4      screenshots.<anonymous closure> (package:screenshots/src/run.dart:42:26)
#5      AppContext.run.<anonymous closure> (package:tool_base/src/base/context.dart:154:29)
#6      _rootRun (dart:async/zone.dart:1184:13)
#7      _CustomZone.run (dart:async/zone.dart:1077:19)
#8      _runZoned (dart:async/zone.dart:1619:10)
#9      runZoned (dart:async/zone.dart:1539:10)
#10     AppContext.run (package:tool_base/src/base/context.dart:153:18)
#11     runInContext (package:screenshots/src/context_runner.dart:16:24)
#12     screenshots (package:screenshots/src/run.dart:41:12)
#13     main (file:///Users/alex/.pub-cache/hosted/pub.dartlang.org/screenshots-2.1.1/bin/main.dart:122:25)
<asynchronous suspension>
#14     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

The emulator actually starts, but screenshots fails with an unhandled exception and no screenshot is generated.

Workaround The workaround seems to be disabling web support:

flutter config --no-enable-web

After disabling web support, screenshots works as expected.

knewter commented 4 years ago

I, too, have this issue. I'll just swap the web configuration off and on when I want to screenshot. I also didn't get CI building the screenshots in Docker yet which means I'm actually toggling stuff on my local dev machine to do this...

devjeff commented 3 years ago

I have the same issue. Maybe it is possible to launch the emulator using "flutter emulators --launch ". I'm not sure, whether it's possible to retrieve the emulator information using this command.

JoseFMP commented 3 years ago

Same issue here. And confirmed, disabling web as described above is a working workaround.