flutter / flutter-intellij

Flutter Plugin for IntelliJ
https://flutter.dev/using-ide
BSD 3-Clause "New" or "Revised" License
1.98k stars 319 forks source link

NullPointerException at io.flutter.dart.FlutterDartAnalysisServer #5787

Open HiroyukiTamura opened 3 years ago

HiroyukiTamura commented 3 years ago

What happened

just open Android Studio

Version information

Android Studio Arctic Fox | 2020.3.1 Patch 2 • Flutter plugin io.flutter 60.1.2

Error getting Flutter sdk information.

Exception

null

java.lang.NullPointerException
    at io.flutter.dart.FlutterDartAnalysisServer.<init>(FlutterDartAnalysisServer.java:72)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:52)
    at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:733)
    at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:49)
    at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:37)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:113)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:67)
    at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:457)
    at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:440)
    at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:25)
    at io.flutter.dart.FlutterDartAnalysisServer.getInstance(FlutterDartAnalysisServer.java:66)
    at io.flutter.editor.WidgetIndentsHighlightingPassFactory.<init>(WidgetIndentsHighlightingPassFactory.java:76)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:52)
    at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:733)
    at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:49)
    at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:37)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:113)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:67)
    at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:457)
    at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:440)
    at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:25)
    at io.flutter.editor.WidgetIndentsHighlightingPassFactory.getInstance(WidgetIndentsHighlightingPassFactory.java:71)
    at io.flutter.editor.WidgetIndentsHighlightingPassFactoryRegistrar.registerHighlightingPassFactory(WidgetIndentsHighlightingPassFactoryRegistrar.java:26)
    at com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPassRegistrarImpl.lambda$reRegisterFactories$0(TextEditorHighlightingPassRegistrarImpl.java:72)
    at com.intellij.openapi.extensions.impl.ExtensionProcessingHelper.forEachExtensionSafe(ExtensionProcessingHelper.java:33)
    at com.intellij.openapi.extensions.ExtensionPointName.forEachExtensionSafe(ExtensionPointName.java:49)
    at com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPassRegistrarImpl.reRegisterFactories(TextEditorHighlightingPassRegistrarImpl.java:72)
    at com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPassRegistrarImpl.serializeCodeInsightPasses(TextEditorHighlightingPassRegistrarImpl.java:78)
    at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl.serializeCodeInsightPasses(DaemonCodeAnalyzerImpl.java:1020)
    at org.jetbrains.kotlin.idea.StartupKt$runActivity$2.accept(startup.kt:25)
    at org.jetbrains.kotlin.idea.StartupKt$runActivity$2.accept(startup.kt)
    at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$safeTransferToEdt$6(NonBlockingReadActionImpl.java:577)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:828)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:330)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:85)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:134)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:190)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:976)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:843)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:454)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:773)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:453)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:828)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:501)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
stevemessick commented 3 years ago

It looks like the Flutter plugin was being initialized before its dependent, Dart, was fully initialized.

@alexander-doroshko Other than dependencies, is there another way to order plugin initialization?

alexander-doroshko commented 3 years ago

@HiroyukiTamura Does it happen each time you start the IDE? If not, do you think it could be related to the Dart plugin update, when the exception happened?

I think such strange exceptions may happen if you update the Dart plugin without restarting the IDE. But I'm not sure how it's possible to get it right after the IDE start. Any hints to reproduce or to investigate the problem are welcome.

HiroyukiTamura commented 3 years ago

@HiroyukiTamura Does it happen each time you start the IDE? If not, do you think it could be related to the Dart plugin update, when the exception happened?

I think such strange exceptions may happen if you update the Dart plugin without restarting the IDE. But I'm not sure how it's possible to get it right after the IDE start. Any hints to reproduce or to investigate the problem are welcome.

No, it happened only once. I think it absolutely related to the Dart plugin update.

The situation is like this; I worked on my Flutter project for the first time in a while. I updated the Dart plugin, Flutter(from 2.2.3 to 2.5.2 on stable channel), and some dependencies on pubspec.yaml and android gradle files. It occurred in the middle of that, so I just noticed the bug mark right after opening AS but it may happened before.