Skip to content

Conversation

lfkdsk
Copy link
Contributor

@lfkdsk lfkdsk commented May 7, 2020

Description

When Flutter project miss platform sub-project (like android or iOS dir), run flutter run will get result like:

No supported devices connected.

this is a confusing message,because devices is supported but miss this sub-project.
So I added log printing in this case, such as:

No supported devices connected.
Follow devices are founded but not support in this project:

Web Server • web-server • web-javascript • Flutter Tools
Chrome     • chrome     • web-javascript • Google Chrome 81.0.4044.138

Is your project missing a platform project in your project /Users/liufengkai/Documents/Code/FlutterSupport/app
Consider running "flutter create ." to create one.

Related Issues

#56315

Tests

I added the following tests:

https://github.com/flutter/flutter/compare/master...lfkdsk:feature-support-miss-platform-project-user-message?expand=1#diff-09cce1e3642fa7c47801e06ff46fcd60

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@lfkdsk lfkdsk changed the title feature: support usermessage and add test. feature: add usermessage when miss platform project May 7, 2020
@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 7, 2020

@jmagman @jamesderlin

@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 7, 2020

#27417

@jamesderlin
Copy link
Contributor

Thanks for the contribution. However, there are existing messages that are supposed to be reported (search through package/flutter_tools for flutter create .), and the reporting is broken.

@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 7, 2020

@jamesderlin
like in packages/flutter_tools/lib/src/resident_runner.dart and report message like:

'Is your project missing an $manifestPath?\nConsider running "flutter create ." to create one.' 

but in flutter run 's situation, error in resident_runner.dart maybe too deep to report? check devices can report missing error in an early pos.

Copy link
Contributor

@Zazo032 Zazo032 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a project has only Android project, but user enabled web and macOS, will this print duplicated lines for each missing platform? Maybe the message could be more like Your project $project is missing the following platform projects: ios, web, macos

@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 7, 2020

@Zazo032
program won't print this user-message when there is an available device.

@Zazo032
Copy link
Contributor

Zazo032 commented May 7, 2020

@Zazo032
program won't print this user-message when there is an available device.

What if only supported platform is Android, the user hasn't an Android device available, and has enabled web and macOS?

@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 7, 2020

@Zazo032
program won't print this user-message when there is an available device.

What if only supported platform is Android, the user hasn't an Android device available, and has enabled web and macOS?

if enable web and macOS, it will print this user-message to notice user if should add some platform sub-projects.

No supported devices connected.
The following devices were found, but they aren't supported in this project

Web Server • web-server • web-javascript • Flutter Tools
Chrome     • chrome     • web-javascript • Google Chrome 81.0.4044.138

Your project /Users/liufengkai/Documents/Code/FlutterSupport/app is missing some platform projects.
 Consider running "flutter create ." in the root project to create them.

maybe we should change some text in user-message to notice user about web, macOS flag.

@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 7, 2020

Is flutter ci build broken? most flutter prs ci is broken.

@Zazo032 Is there any more review comments?

@Zazo032
Copy link
Contributor

Zazo032 commented May 7, 2020

You'll have to wait for Flutter team's feedback

@Zazo032
Copy link
Contributor

Zazo032 commented May 7, 2020

Also, there's a failing test:

Logs
02:15 +299: test/commands.shard/permeable/test_test.dart: flutter test should report which user created widget caused the error                                                                        Expected: contains "Follow devices are founded but not support in this project: " ignoring whitespace.
  Actual: 'No supported devices connected.\n'
            'The following devices were found, but they aren\'t supported in this project\n'
            '\n'
            'mock-name • mock-id • android-arm • api-14 (emulator)\n'
            '\n'
            ''
#0      fail (package:test_api/src/frontend/expect.dart:154:30)
#1      _expect (package:test_api/src/frontend/expect.dart:148:3)
#2      expect (package:test_api/src/frontend/expect.dart:60:3)
#3      main.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart:281:9)
<asynchronous suspension>
#4      main.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart)
#5      testUsingContext.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter_tools/test/src/context.dart:152:42)
#6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#7      _rootRun (dart:async/zone.dart:1184:13)
#8      _CustomZone.run (dart:async/zone.dart:1077:19)
#9      _runZoned (dart:async/zone.dart:1619:10)
#10     runZoned (dart:async/zone.dart:1539:10)
#11     AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#12     testUsingContext.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter_tools/test/src/context.dart:141:30)
#13     _rootRun (dart:async/zone.dart:1184:13)
#14     _CustomZone.run (dart:async/zone.dart:1077:19)
#15     _runZoned (dart:async/zone.dart:1619:10)
#16     runZonedGuarded (dart:async/zone.dart:1608:12)
#17     runZoned (dart:async/zone.dart:1536:12)
#18     testUsingContext.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter_tools/test/src/context.dart:139:18)
#19     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#20     _rootRun (dart:async/zone.dart:1184:13)
#21     _CustomZone.run (dart:async/zone.dart:1077:19)
#22     _runZoned (dart:async/zone.dart:1619:10)
#23     runZoned (dart:async/zone.dart:1539:10)
#24     AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#25     testUsingContext.<anonymous closure>.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter_tools/test/src/context.dart:105:22)
#26     runInContext.runnerWrapper (package:flutter_tools/src/context_runner.dart:63:18)
<asynchronous suspension>
#27     runInContext.runnerWrapper (package:flutter_tools/src/context_runner.dart)
#28     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#29     _rootRun (dart:async/zone.dart:1184:13)
#30     _CustomZone.run (dart:async/zone.dart:1077:19)
#31     _runZoned (dart:async/zone.dart:1619:10)
#32     runZoned (dart:async/zone.dart:1539:10)
#33     AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#34     runInContext (package:flutter_tools/src/context_runner.dart:66:24)
#35     testUsingContext.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter_tools/test/src/context.dart:104:11)
#36     Declarer.test.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:172:27)
<asynchronous suspension>
#37     Declarer.test.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart)
#38     Invoker.waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:246:15)
#39     _rootRun (dart:async/zone.dart:1184:13)
#40     _CustomZone.run (dart:async/zone.dart:1077:19)
#41     _runZoned (dart:async/zone.dart:1619:10)
#42     runZoned (dart:async/zone.dart:1539:10)
#43     Invoker.waitForOutstandingCallbacks (package:test_api/src/backend/invoker.dart:243:5)
#44     Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:170:33)
#45     _rootRun (dart:async/zone.dart:1184:13)
#46     _CustomZone.run (dart:async/zone.dart:1077:19)
#47     _runZoned (dart:async/zone.dart:1619:10)
#48     runZoned (dart:async/zone.dart:1539:10)
#49     Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:169:13)
#50     Invoker._onRun.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/invoker.dart:400:30)
#51     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#52     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#53     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#54     _rootRun (dart:async/zone.dart:1180:38)
#55     _CustomZone.run (dart:async/zone.dart:1077:19)
#56     _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#57     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#58     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#59     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#60     _rootRun (dart:async/zone.dart:1184:13)
#61     _CustomZone.run (dart:async/zone.dart:1077:19)
#62     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1003:23)
#63     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
#64     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#65     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#66     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:12)
02:15 +299: test/commands.shard/hermetic/run_test.dart: run run app exist with unsupported device message when missing platform project                                                                
Your project /.tmp_rand0/flutter_run_test.rand0 is missing some platform projects.
 Consider running "flutter create ." in the root project to create them.
02:15 +299 -1: test/commands.shard/hermetic/run_test.dart: run run app exist with unsupported device message when missing platform project [E]                                                         
  Expected: contains "Follow devices are founded but not support in this project: " ignoring whitespace.
    Actual: 'No supported devices connected.\n'
              'The following devices were found, but they aren\'t supported in this project\n'
              '\n'
              'mock-name • mock-id • android-arm • api-14 (emulator)\n'
              '\n'
              ''
  package:test_api                                     expect
  test/commands.shard/hermetic/run_test.dart 281:9     main.<fn>.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async                                           _asyncErrorWrapperHelper
  test/src/context.dart 141:30                         testUsingContext.<fn>.<fn>.<fn>.<fn>
  dart:async                                           runZoned
  test/src/context.dart 139:18                         testUsingContext.<fn>.<fn>.<fn>
  package:flutter_tools/src/base/context.dart 150:29   AppContext.run.<fn>
  dart:async                                           runZoned
  package:flutter_tools/src/base/context.dart 149:18   AppContext.run
  test/src/context.dart 105:22                         testUsingContext.<fn>.<fn>
  package:flutter_tools/src/context_runner.dart 63:18  runInContext.runnerWrapper
  ===== asynchronous gap ===========================
  dart:async                                           _asyncThenWrapperHelper
  package:flutter_tools/src/context_runner.dart        runInContext.runnerWrapper
  package:flutter_tools/src/base/context.dart 150:29   AppContext.run.<fn>
  dart:async                                           runZoned
  package:flutter_tools/src/base/context.dart 149:18   AppContext.run
  package:flutter_tools/src/context_runner.dart 66:24  runInContext
  test/src/context.dart 104:11                         testUsingContext.<fn>

@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 7, 2020

Also, there's a failing test:

Logs

fix it.

@jmagman jmagman added the tool Affects the "flutter" command-line tool. See also t: labels. label May 8, 2020
@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 11, 2020

@jmagman

@zanderso zanderso requested a review from jmagman May 14, 2020 20:40
Comment on lines 836 to 837
globals.printStatus('');
globals.printStatus(userMessages.flutterMissPlatformProject(FlutterProject.current().directory.path));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of showing unsupported devices when no supported devices are found, but the "Your project is missing platform projects, run flutter create." message is far too strong, and will be alarming to the much more common scenario of people who are trying to debug their Android app just forgot to plug in their phone.

I think just mentioning that the discovered devices are unsupported will be a sufficient hint.

Copy link
Member

@jmagman jmagman May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could change that message to something less alarming like:

If you would like your app to run on Android or web, consider running `flutter create .` to generate projects for these platforms.

where "<Android or web>" are examples generated based on the discovered but unsupported devices.

Copy link
Contributor Author

@lfkdsk lfkdsk May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supported it. message alarm like:

No supported devices connected.
The following devices were found, but are not supported by this project:

MIX 2      • 2e7847af   • android-arm64  • Android 9 (API 28)
Web Server • web-server • web-javascript • Flutter Tools
Chrome     • chrome     • web-javascript • Google Chrome 81.0.4044.138

Your project /Users/liufengkai/Documents/Code/FlutterSupport/a_test is missing some platform projects.
If you would like your app to run on android or web, consider running `flutter create .` to generate projects for these platforms.

<android or web> generated by unsupported devices.

@jmagman jmagman added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 19, 2020
@jamesderlin
Copy link
Contributor

  1. If we can't fix the existing code meant to cover this case, is it dead code that can be removed?

  2. Why is this tied to connected devices? I'm guessing that we depend on connected devices to determine which project directories to look for? How about instead checking for project directories for all supported platforms and emitting a message about flutter create . if none of them exists?

@jmagman
Copy link
Member

jmagman commented May 19, 2020

@jamesderlin I responded in #56315 (comment).

@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 19, 2020

@jamesderlin fix typo and add wanted feature.

@lfkdsk lfkdsk requested a review from jmagman May 19, 2020 15:44
@lfkdsk
Copy link
Contributor Author

lfkdsk commented May 26, 2020

@jmagman

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this. I think this will be helpful to our users!

A few comments and suggestions.

@lfkdsk lfkdsk requested a review from jmagman June 1, 2020 09:31
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for the tests! A few very minor nits.

@zanderso And additional comments here?

Copy link
Member

@zanderso zanderso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm after addressing jmagman's comments and a small cleanup suggestion to try.

@lfkdsk lfkdsk requested a review from jmagman June 3, 2020 10:38
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you so much!

@jmagman jmagman removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 3, 2020
@jmagman jmagman merged commit 6c8d7b0 into flutter:master Jun 3, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants