Fix Android Studio 2025.2 project open hang by using StartupActivity (projects with missing .idea directories)#8710
Conversation
pq
left a comment
There was a problem hiding this comment.
Cool!
Do you have any insight into what was causing the hangs w/ the Kotlin-migrated code? Was it anything we could have noticed in a code review? (Do you recall if you used the IntelliJ tooling for the conversion BTW or was that Gemini?)
| // Instead, we let the Platform open the project normally, and then apply our configuration here. | ||
| // This includes ensuring the module type is set to 'flutter' (for icons/facets) and enabling the Dart SDK. | ||
| // See https://github.com/flutter/flutter-intellij/issues/8661 | ||
| for (com.intellij.openapi.module.Module module : FlutterModuleUtils.getModules(project)) { |
There was a problem hiding this comment.
Could you remove this qualified name by adding an import for com.intellij.openapi.module? (That seems generally preferred -- Gemini will confirm -- and is consistent with the rest of our codebase.)
Unless there's a conflict?
There was a problem hiding this comment.
Could you update your prompt to do this in general?
There was a problem hiding this comment.
I didn't use the "finalize this code before review" prompt, but I should have. Yes, this is something we should add to the prompts.md file.
| } | ||
|
|
||
| // Ensure Flutter project configuration is applied. | ||
| // This logic was previously in FlutterStudioProjectOpenProcessor. However, that processor |
There was a problem hiding this comment.
This comment is great. Thanks!
|
Thinking ahead to automated, if not just manual testing, could you consider adding some notes about how this fix was verified and how we can be sure removing Thanks! |
| for (com.intellij.openapi.module.Module module : FlutterModuleUtils.getModules(project)) { | ||
| if (FlutterModuleUtils.declaresFlutter(module) && !FlutterModuleUtils.isFlutterModule(module)) { | ||
| ApplicationManager.getApplication().invokeLater(() -> { | ||
| ApplicationManager.getApplication().runWriteAction(() -> { |
There was a problem hiding this comment.
Consider adding logging here?
And maybe a note to add analytics when we have them?
Updating the commit message. |
…(projects with missing .idea directories) The custom `FlutterStudioProjectOpenProcessor` was causing hangs and crashes due to threading issues when delegating to the Platform's project opener in newer Android Studio versions. This change: - Removes `FlutterStudioProjectOpenProcessor` entirely, allowing the robust standard Platform processor to handle project opening. - Moves the necessary Flutter configuration (setting module type, enabling Dart SDK) to FlutterStudioStartupActivity, ensuring it runs safely after startup. Fixes flutter#8661
…ectOpenProcessor FlutterProjectOpenProcessor silently failed to open Flutter projects without a .idea directory because getDelegateImportProvider() returned null when no other processor could claim the project. Since this processor was registered with order="first", no fallback occurred. Apply the same fix pattern as PR flutter#8710 (Android Studio): - Remove FlutterProjectOpenProcessor.kt - Remove its <projectOpenProcessor> registration from plugin.xml - Add module-type-fixing logic to FlutterInitializer (startup activity) This lets the platform's default project opener handle opening, then FlutterInitializer configures Flutter module type and Dart SDK after the project is loaded. Fixes flutter#8845 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ectOpenProcessor FlutterProjectOpenProcessor silently failed to open Flutter projects without a .idea directory because getDelegateImportProvider() returned null when no other processor could claim the project. Since this processor was registered with order="first", no fallback occurred. Apply the same fix pattern as PR flutter#8710 (Android Studio): - Remove FlutterProjectOpenProcessor.kt - Remove its <projectOpenProcessor> registration from plugin.xml - Add module-type-fixing logic to FlutterInitializer (startup activity) - Add changelog entry This lets the platform's default project opener handle opening, then FlutterInitializer configures Flutter module type and Dart SDK after the project is loaded. Fixes flutter#8845 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ectOpenProcessor FlutterProjectOpenProcessor silently failed to open Flutter projects without a .idea directory because getDelegateImportProvider() returned null when no other processor could claim the project. Since this processor was registered with order="first", no fallback occurred. Apply the same fix pattern as PR flutter#8710 (Android Studio): - Remove FlutterProjectOpenProcessor.kt - Remove its <projectOpenProcessor> registration from plugin.xml - Add module-type-fixing logic to FlutterInitializer (startup activity) - Add changelog entry This lets the platform's default project opener handle opening, then FlutterInitializer configures Flutter module type and Dart SDK after the project is loaded. Fixes flutter#8845
…ectOpenProcessor FlutterProjectOpenProcessor silently failed to open Flutter projects without a .idea directory because getDelegateImportProvider() returned null when no other processor could claim the project. Since this processor was registered with order="first", no fallback occurred. Apply the same fix pattern as PR flutter#8710 (Android Studio): - Remove FlutterProjectOpenProcessor.kt - Remove its <projectOpenProcessor> registration from plugin.xml - Add module-type-fixing logic to FlutterInitializer (startup activity) - Add changelog entry This lets the platform's default project opener handle opening, then FlutterInitializer configures Flutter module type and Dart SDK after the project is loaded. Fixes flutter#8845
…cessor (#8846) ## Description The custom `FlutterProjectOpenProcessor` silently fails to open Flutter projects that lack a `.idea` directory in IntelliJ IDEA (Community and Ultimate). When `getDelegateImportProvider()` finds no other processor that can claim the project, `openProjectAsync()` returns `null` — a silent failure with no error logged. Since this processor is registered with `order="first"`, no other processor gets a chance to try. This is the IntelliJ IDEA equivalent of PR #8710, which fixed the same class of issue for Android Studio by removing `FlutterStudioProjectOpenProcessor`. ### Changes - **Removed** `FlutterProjectOpenProcessor.kt` entirely - **Removed** its `<projectOpenProcessor>` registration from `plugin.xml` - **Added** module-type-fixing logic to `FlutterInitializer` (the existing IntelliJ IDEA startup activity) — sets Flutter module type and enables Dart SDK for unconfigured modules - **Added** changelog entry This lets the platform's default project opener handle opening, then `FlutterInitializer` configures Flutter-specific settings after the project is loaded — the same pattern used in the Android Studio fix. ### Reproduction ```bash flutter create test_app && rm -rf test_app/.idea ``` Then open `test_app` via File > Open in IntelliJ IDEA — previously nothing happened, now the project opens correctly. ### Testing Tested with: - IntelliJ IDEA CE 2025.2 - Android Studio 2025.2.3.9 (sandboxed via `./gradlew runIde`) - Flutter 3.8.1 / Dart 3.8.1 - macOS Verified: - [x] Opening a Flutter project without `.idea` directory works in IntelliJ IDEA - [x] Opening a Flutter project with existing `.idea` directory still works - [x] No regressions in Android Studio (sandboxed `runIde`) - [x] IDE logs show `FlutterInitializer` running correctly, no errors Fixes #8845 Related: #8661, #8710 --------- Co-authored-by: Georgii Kostenko <kesha1000@gmail.com>
The custom
FlutterStudioProjectOpenProcessorwas causing hangs and crashes due to threading issues when delegating to the Platform's project opener in newer Android Studio versions.This change:
FlutterStudioProjectOpenProcessorentirely, allowing the robust standard Platform processor to handle project opening.Fixes #8661
This issue was identified by having the open project dialog not work on a valid flutter project, without a
.ideadirectory:flutter create flutter_no_idea && cd flutter_no_idea && rm -rf .ideaFlutter and Android Studio versions: