Skip to content

Fix Android Studio 2025.2 project open hang by using StartupActivity (projects with missing .idea directories)#8710

Merged
jwren merged 1 commit intoflutter:mainfrom
jwren:8661-2
Jan 17, 2026
Merged

Fix Android Studio 2025.2 project open hang by using StartupActivity (projects with missing .idea directories)#8710
jwren merged 1 commit intoflutter:mainfrom
jwren:8661-2

Conversation

@jwren
Copy link
Member

@jwren jwren commented Jan 16, 2026

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 #8661

This issue was identified by having the open project dialog not work on a valid flutter project, without a .idea directory:

flutter create flutter_no_idea && cd flutter_no_idea && rm -rf .idea

Flutter and Android Studio versions:

Flutter 3.41.0-1.0.pre-93 • channel [user-branch]
Framework • revision 5182dc0e89 (23 minutes ago) • 2026-01-16 15:27:15 -0800
Engine • hash 210577698f36ac84ce1c12e164f5024e23baf3fb (revision 3b7caba768) (2
days ago) • 2026-01-14 01:07:10.000Z
Tools • Dart 3.12.0 (build 3.12.0-17.0.dev) • DevTools 2.54.0
Android Studio Otter | 2025.2.1 Canary 5
Build #AI-252.25557.131.2521.14240541, built on October 9, 2025
Runtime version: 21.0.8+-14196175-b1038.72 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 15.7.3
Kotlin analyzer version: 2.2.255-dev-255
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 12
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
  gradle.phased.sync.enabled=true
Non-Bundled Plugins:
  Dart (252.25557.23)
  io.flutter (SNAPSHOT)

@jwren jwren requested a review from helin24 January 16, 2026 20:07
@jwren jwren added the 🤖 AI-assisted For PRs with significant code generated by AI label Jan 16, 2026
Copy link
Collaborator

@pq pq left a comment

Choose a reason for hiding this comment

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

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)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you update your prompt to do this in general?

Copy link
Member Author

Choose a reason for hiding this comment

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

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is great. Thanks!

@pq
Copy link
Collaborator

pq commented Jan 16, 2026

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 FlutterStudioProjectOpenProcessor doesn't cause any behavior regressions? (Or even just some notes on what to look out for?)

Thanks!

for (com.intellij.openapi.module.Module module : FlutterModuleUtils.getModules(project)) {
if (FlutterModuleUtils.declaresFlutter(module) && !FlutterModuleUtils.isFlutterModule(module)) {
ApplicationManager.getApplication().invokeLater(() -> {
ApplicationManager.getApplication().runWriteAction(() -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding logging here?

And maybe a note to add analytics when we have them?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@jwren
Copy link
Member Author

jwren commented Jan 16, 2026

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 FlutterStudioProjectOpenProcessor doesn't cause any behavior regressions? (Or even just some notes on what to look out for?)

Thanks!

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
@jwren jwren merged commit f61d7c7 into flutter:main Jan 17, 2026
7 of 8 checks passed
0ttik pushed a commit to 0ttik/flutter-intellij that referenced this pull request Mar 9, 2026
…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>
0ttik pushed a commit to 0ttik/flutter-intellij that referenced this pull request Mar 9, 2026
…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>
0ttik pushed a commit to 0ttik/flutter-intellij that referenced this pull request Mar 9, 2026
…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
0ttik pushed a commit to 0ttik/flutter-intellij that referenced this pull request Mar 11, 2026
…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
pq pushed a commit that referenced this pull request Mar 12, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 AI-assisted For PRs with significant code generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flutter plugin failed opening some projects

3 participants