Running kotlin-inspection sample fails on Android Studio Dolphin
Running kotlin-inspection included sample plugin results in a following exception:
Internal error compiling script.
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at liveplugin.pluginrunner.kotlin.KotlinPluginCompiler.compile(KotlinPluginRunner.kt:138)
at liveplugin.pluginrunner.kotlin.KotlinPluginRunner.setup(KotlinPluginRunner.kt:67)
at liveplugin.pluginrunner.RunPluginActionsKt$runWith$1.invoke(RunPluginActions.kt:75)
at liveplugin.pluginrunner.RunPluginActionsKt$runInBackground$2.run(RunPluginActions.kt:96)
at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:436)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:120)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:496)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:244)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:244)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalStateException: The provided plugin org.jetbrains.kotlin.android.synthetic.AndroidComponentRegistrar is not compatible with this version of compiler
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:592)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:132)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:172)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:426)
at liveplugin.pluginrunner.kotlin.compiler.EmbeddedCompilerRunnerKt.compile(EmbeddedCompilerRunner.kt:42) ... 28 more
Caused by: java.lang.AbstractMethodError: Receiver class org.jetbrains.kotlin.android.synthetic.AndroidComponentRegistrar does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(org.jetbrains.kotlin.com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:584) ... 33 more
This is with
Android Studio Dolphin | 2021.3.1 Beta 5
Build #AI-213.7172.25.2113.8774922, built on June 28, 2022
Runtime version: 11.0.14.1+1-b2043.45 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.19.0-1-manjaro
LivePlugin (0.7.3 beta)
Kotlin 213-1.7.0-release-for-android-studio-AS6777.52
(From what I can see, 0.7.3 beta is pretty old, but this is the latest one I see through official plugin marketplace.)
Let me look into it. I might release a patched version.
At the moment because of changes in IntelliJ API and dependencies, plugins for the latest version of IntelliJ are basically not compatible with Android studio (which I think is about a year behind in terms of IJ API). I had to upgrade plugin dependencies and API to make it work in the latest IntelliJ but then it cannot be used in Android studio.
The underlying problem is that there are kotlin compiler plugins bundled with IDE which are not always compatible (and not even required) with Kotlin version in LivePlugin.
Same issue.
Android Studio Dolphin | 2021.3.1 Build #AI-213.7172.25.2113.9014738, built on August 31, 2022 Runtime version: 11.0.13+0-b1751.21-8125866 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 12.6 LivePlugin (0.7.3 beta)
Also seeing this issue, and I believe any file with // depends-on-plugin org.jetbrains.kotlin will have this issue as well, which seems like it makes it impossible to develop any Kotlin PSI aware code with LivePlugin. Am I missing something?
Is there any solution for this issue?
I met the same issue in Android Studio Dolphin.
Sorry there was no action on the issue. I think it was fixed in https://github.com/dkandalov/live-plugin/releases/tag/v0.7.5beta
But as mentioned above to fix it in Android Studio Dolphin I'll probably need to create a release branch from LivePlugin 0.7.3. It's totally doable but takes effort.
LivePlugin compiles Kotlin source code with its own bundled embedded compiler and then runs the compiled code using stdlib bundled with IDE. The problem is that Kotlin version bundled with IntelliJ is changing too quickly to be compatible with Android Studio. E.g. the latest IntelliJ EAP has Kotlin 1.8 so for LivePlugin to work in EAP, I'll probably have to upgrade to Kotlin 1.7 which won't work in Android Studious 🙄
Maybe it's worth changing the way it works and, for example, make mini-plugin classpaths more configurable 🤔 Or they could use stdlib bundled with LivePlugin.
As a workaround you might be to write mini-plugins in Groovy because it doesn't change that much between IDE versions.
This works now for
Android Studio Electric Eel | 2022.1.1 Beta 5
Build #AI-221.6008.13.2211.9237616, built on October 31, 2022
Runtime version: 11.0.15+0-b2043.56-8887301 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.0.8-arch1-1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Registry:
external.system.auto.import.disabled=true
debugger.mayBringFrameToFrontOnBreakpoint=false
ide.text.editor.with.preview.show.floating.toolbar=false
LivePlugin (0.8.2 beta)
If the issue is only Android Studio having old IntelliJ, then I think we can just wait out until they update. This issue can be closed, as far as I'm concerned.