Skip to content

Commit f7c2bd0

Browse files
authored
Revert "Fix unable to find bundled Java version (#119244)" (#119981)
This reverts commit 57fd50f.
1 parent 57fd50f commit f7c2bd0

File tree

3 files changed

+6
-182
lines changed

3 files changed

+6
-182
lines changed

AUTHORS

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,4 @@ Jingyi Chen <[email protected]>
100100
Junhua Lin <[email protected]>
101101
Tomasz Gucio <[email protected]>
102102
Jason C.H <[email protected]>
103-
Hubert Jóźwiak <[email protected]>
104-
Eli Albert <[email protected]>
103+
Hubert Jóźwiak <[email protected]>

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

+5-16
Original file line numberDiff line numberDiff line change
@@ -441,22 +441,11 @@ class AndroidStudio implements Comparable<AndroidStudio> {
441441
return;
442442
}
443443

444-
final String javaPath;
445-
if (globals.platform.isMacOS) {
446-
if (version != null && version.major < 2020) {
447-
javaPath = globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home');
448-
} else if (version != null && version.major == 2022) {
449-
javaPath = globals.fs.path.join(directory, 'jbr', 'Contents', 'Home');
450-
} else {
451-
javaPath = globals.fs.path.join(directory, 'jre', 'Contents', 'Home');
452-
}
453-
} else {
454-
if (version != null && version.major == 2022) {
455-
javaPath = globals.fs.path.join(directory, 'jbr');
456-
} else {
457-
javaPath = globals.fs.path.join(directory, 'jre');
458-
}
459-
}
444+
final String javaPath = globals.platform.isMacOS ?
445+
version != null && version.major < 2020 ?
446+
globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home') :
447+
globals.fs.path.join(directory, 'jre', 'Contents', 'Home') :
448+
globals.fs.path.join(directory, 'jre');
460449
final String javaExecutable = globals.fs.path.join(javaPath, 'bin', 'java');
461450
if (!globals.processManager.canRun(javaExecutable)) {
462451
_validationMessages.add('Unable to find bundled Java version.');

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

-164
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ const Map<String, Object> macStudioInfoPlist2020_3 = <String, Object>{
5656
},
5757
};
5858

59-
const Map<String, Object> macStudioInfoPlist2022_1 = <String, Object>{
60-
'CFBundleGetInfoString': 'Android Studio 2022.1, build AI-221.6008.13.2211.9477386. Copyright JetBrains s.r.o., (c) 2000-2023',
61-
'CFBundleShortVersionString': '2022.1',
62-
'CFBundleVersion': 'AI-221.6008.13.2211.9477386',
63-
'JVMOptions': <String, Object>{
64-
'Properties': <String, Object>{
65-
'idea.vendor.name' : 'Google',
66-
'idea.paths.selector': 'AndroidStudio2022.1',
67-
'idea.platform.prefix': 'AndroidStudio',
68-
},
69-
},
70-
};
71-
7259
const Map<String, Object> macStudioInfoPlistEAP = <String, Object>{
7360
'CFBundleGetInfoString': 'Android Studio EAP AI-212.5712.43.2112.8233820, build AI-212.5712.43.2112.8233820. Copyright JetBrains s.r.o., (c) 2000-2022',
7461
'CFBundleShortVersionString': 'EAP AI-212.5712.43.2112.8233820',
@@ -499,84 +486,6 @@ void main() {
499486
Platform: () => platform,
500487
PlistParser: () => plistUtils,
501488
});
502-
503-
testUsingContext('Can find Android Studio 2020.3 bundled Java version on Mac', () {
504-
final String studioInApplicationPlistFolder = globals.fs.path.join(
505-
'/',
506-
'Application',
507-
'Android Studio.app',
508-
'Contents',
509-
);
510-
globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
511-
512-
final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
513-
plistUtils.fileContents[plistFilePath] = macStudioInfoPlist2020_3;
514-
processManager.addCommand(FakeCommand(
515-
command: <String>[
516-
globals.fs.path.join(studioInApplicationPlistFolder, 'jre', 'Contents', 'Home', 'bin', 'java'),
517-
'-version',
518-
],
519-
stderr: '123',
520-
)
521-
);
522-
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
523-
globals.fs.directory(studioInApplicationPlistFolder).parent.path,
524-
)!;
525-
526-
expect(studio.javaPath, equals(globals.fs.path.join(
527-
studioInApplicationPlistFolder,
528-
'jre',
529-
'Contents',
530-
'Home',
531-
)));
532-
}, overrides: <Type, Generator>{
533-
FileSystem: () => fileSystem,
534-
FileSystemUtils: () => fsUtils,
535-
ProcessManager: () => processManager,
536-
// Custom home paths are not supported on macOS nor Windows yet,
537-
// so we force the platform to fake Linux here.
538-
Platform: () => platform,
539-
PlistParser: () => plistUtils,
540-
});
541-
542-
testUsingContext('Can find Android Studio 2022.1 bundled Java version on Mac', () {
543-
final String studioInApplicationPlistFolder = globals.fs.path.join(
544-
'/',
545-
'Application',
546-
'Android Studio.app',
547-
'Contents',
548-
);
549-
globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
550-
551-
final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
552-
plistUtils.fileContents[plistFilePath] = macStudioInfoPlist2022_1;
553-
processManager.addCommand(FakeCommand(
554-
command: <String>[
555-
globals.fs.path.join(studioInApplicationPlistFolder, 'jbr', 'Contents', 'Home', 'bin', 'java'),
556-
'-version',
557-
],
558-
stderr: '123',
559-
)
560-
);
561-
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
562-
globals.fs.directory(studioInApplicationPlistFolder).parent.path,
563-
)!;
564-
565-
expect(studio.javaPath, equals(globals.fs.path.join(
566-
studioInApplicationPlistFolder,
567-
'jbr',
568-
'Contents',
569-
'Home',
570-
)));
571-
}, overrides: <Type, Generator>{
572-
FileSystem: () => fileSystem,
573-
FileSystemUtils: () => fsUtils,
574-
ProcessManager: () => processManager,
575-
// Custom home paths are not supported on macOS nor Windows yet,
576-
// so we force the platform to fake Linux here.
577-
Platform: () => platform,
578-
PlistParser: () => plistUtils,
579-
});
580489
});
581490

582491
late FileSystem windowsFileSystem;
@@ -687,38 +596,6 @@ void main() {
687596
ProcessManager: () => FakeProcessManager.any(),
688597
});
689598

690-
testUsingContext('Can find Android Studio 2020.3 bundled Java version on Windows', () {
691-
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio2020.3\.home')
692-
..createSync(recursive: true)
693-
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
694-
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
695-
.createSync(recursive: true);
696-
697-
final AndroidStudio studio = AndroidStudio.allInstalled().single;
698-
699-
expect(studio.javaPath, equals(r'C:\Program Files\AndroidStudio\jre'));
700-
}, overrides: <Type, Generator>{
701-
Platform: () => windowsPlatform,
702-
FileSystem: () => windowsFileSystem,
703-
ProcessManager: () => FakeProcessManager.any(),
704-
});
705-
706-
testUsingContext('Can find Android Studio 2022.1 bundled Java version on Windows', () {
707-
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio2022.1\.home')
708-
..createSync(recursive: true)
709-
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
710-
windowsFileSystem.directory(r'C:\Program Files\AndroidStudio')
711-
.createSync(recursive: true);
712-
713-
final AndroidStudio studio = AndroidStudio.allInstalled().single;
714-
715-
expect(studio.javaPath, equals(r'C:\Program Files\AndroidStudio\jbr'));
716-
}, overrides: <Type, Generator>{
717-
Platform: () => windowsPlatform,
718-
FileSystem: () => windowsFileSystem,
719-
ProcessManager: () => FakeProcessManager.any(),
720-
});
721-
722599
group('Installation detection on Linux', () {
723600
late FileSystemUtils fsUtils;
724601

@@ -809,47 +686,6 @@ void main() {
809686
Platform: () => linuxPlatform,
810687
ProcessManager: () => FakeProcessManager.any(),
811688
});
812-
813-
testUsingContext('Can find Android Studio 2020.3 bundled Java version on Linux', () {
814-
const String studioHomeFilePath = '$homeLinux/.cache/Google/AndroidStudio2020.3/.home';
815-
const String studioInstallPath = '$homeLinux/AndroidStudio';
816-
817-
globals.fs.file(studioHomeFilePath)
818-
..createSync(recursive: true)
819-
..writeAsStringSync(studioInstallPath);
820-
821-
globals.fs.directory(studioInstallPath).createSync();
822-
823-
final AndroidStudio studio = AndroidStudio.allInstalled().single;
824-
825-
expect(studio.javaPath, equals('$studioInstallPath/jre'));
826-
}, overrides: <Type, Generator>{
827-
FileSystem: () => fileSystem,
828-
FileSystemUtils: () => fsUtils,
829-
Platform: () => linuxPlatform,
830-
ProcessManager: () => FakeProcessManager.any(),
831-
});
832-
833-
testUsingContext('Can find Android Studio 2022.1 bundled Java version on Linux', () {
834-
const String studioHomeFilePath =
835-
'$homeLinux/.cache/Google/AndroidStudio2022.1/.home';
836-
const String studioInstallPath = '$homeLinux/AndroidStudio';
837-
838-
globals.fs.file(studioHomeFilePath)
839-
..createSync(recursive: true)
840-
..writeAsStringSync(studioInstallPath);
841-
842-
globals.fs.directory(studioInstallPath).createSync();
843-
844-
final AndroidStudio studio = AndroidStudio.allInstalled().single;
845-
846-
expect(studio.javaPath, equals('$studioInstallPath/jbr'));
847-
}, overrides: <Type, Generator>{
848-
FileSystem: () => fileSystem,
849-
FileSystemUtils: () => fsUtils,
850-
Platform: () => linuxPlatform,
851-
ProcessManager: () => FakeProcessManager.any(),
852-
});
853689
});
854690
}
855691

0 commit comments

Comments
 (0)