Fix: fix android studio 4.1 plugin path for macOS#69364
Fix: fix android studio 4.1 plugin path for macOS#69364jonahwilliams merged 7 commits intoflutter:masterfrom
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
jonahwilliams
left a comment
There was a problem hiding this comment.
This will need a test before we can submit it. The existing test file is https://github.com/flutter/flutter/blob/master/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart. Though unfortunately we don't have any coverage of this code path yet :(
Ideally there would be two tests, one that looks up the < 4.1 path and one that looks up the > 4.1 path. This could be done by setting the platform the macOS using a FakePlatform(operatingSystem: 'macos') and then checking that the plugin path is correct for a given major/minor version
Hi @jonahwilliams, thanks for your kind reply. I also test my code in my own dev env(macOS): on my modified channel, the flutter doctor works well again: |
0b2b39a to
0d6bf4d
Compare
| 'AndroidStudio$major.$minor', | ||
| ); | ||
| /// plugin path of Android Studio has been changed after version 4.1. | ||
| if(double.parse('$major.$minor') >= 4.1) { |
There was a problem hiding this comment.
Instead of concatenation these numbers parsing the string, check for the major and minor version separately:
(if major >= 4 && minor >= 1) {
| 'Application Support', | ||
| pathsSelectorValue, | ||
| ); | ||
| : double.parse('$major.$minor') >= 4.1 |
There was a problem hiding this comment.
The nested ternary expression is a big hard to read. I would break this up into an if (and use the separate major/minor checks like below):
String presetPluginsPath;
if (pathsSelectorValue != null) {
if (major >= 4 && minor >= 1) {
...
} else {
...
}
}
|
This is looking great, just a few small comments! |
| ); | ||
| }); | ||
|
|
||
| testUsingContext('Can discover Android Studio >=4.1 location on Mac', () { |
There was a problem hiding this comment.
This is kind of a nit, but the spacing in these tests makes them a bit hard to read. I would generally split up tests into 3 sections:
- creating objects/mocks and setting up state
- performing the action to be tested
- making expectations about the results
There was a problem hiding this comment.
This is kind of a nit, but the spacing in these tests makes them a bit hard to read. I would generally split up tests into 3 sections:
- creating objects/mocks and setting up state
- performing the action to be tested
- making expectations about the results
Hi @jonahwilliams ,
The devil is in the detail. I really sorry for having overlooked the code style.
Thank you very much for your suggestion.It's this kind of suggestion that I strive for to help me keep improving.
Best wishes!😁
|
You have a few minor analysis warnings that need to be cleaned up, otherwise it LGTM! |
| FileSystem: () => fileSystem, | ||
| FileSystemUtils: () => fsUtils, | ||
| ProcessManager: () => FakeProcessManager.any(), | ||
| // Custom home paths are not supported on macOS nor Windows yet, |
There was a problem hiding this comment.
This comment actually seems wrong - this is testing mac right?
There was a problem hiding this comment.
This comment actually seems wrong - this is testing mac right?
in fact, I don't have a wins pc to run this test. so i just copy this comment from other test case that in the same 'group' func (line 202).
solved. |
|
Thank you for the bug fix @Mokusesei , its much appreciated! |
|
I am reverting due to crashes it causes: #69863 |
|
cc @Mokusesei |
#69954 fixed i'm so sorry for that.☕️ |
|
No problem @Mokusesei. Null errors are tricky to spot. This is a great real-world example of why we're adding null safety to Dart! |
Yeah, I think I will get a huge buzz from that feature! |


Description
Plugin path of android studio4.1 in MacOS has been changed(now is at HOME_DIR_PATH/Library/Application Support/Google/AndroidStudiox.x), which makes cmd 'flutter doctor' print wrong logs!
Related Issues
None yet!
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.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.