Status Update
Comments
da...@google.com <da...@google.com>
an...@google.com <an...@google.com>
js...@google.com <js...@google.com>
ja...@google.com <ja...@google.com> #2
What happened here: we added androidx.compose.compiler.plugins.kotlin:strongSkipping
to the newer version Compose compiler plugin, but the 2.0.0-RC3
<- I checked the libs.versions.toml
file used by the attached "MyApplication.zip"), it seems to use the option (androidx.compose.compiler.plugins.kotlin:strongSkipping
) by default. And the default option will be passed to Android Studio somewhere
I believe this will be fixed when we update the compose compiler plugin with the next IJ release merge to the Studio, but it will be a few months later.
A simple temporary workaround is applying the following patch to the IntelliJ for Studio (filter out the new unknown option).
gh...@google.com <gh...@google.com> #3
Instead of patching the Kotlin IDE plugin in IntelliJ, I think it will be easier to patch our bundled Compose compiler plugin. You can add a new patch file under tools/adt/idea/compose-ide-plugin/compose-compiler
to handle this error more gracefully. For example, you could edit ComposePlugin.kt#processOption
so that it does not throw in the else
branch (I have not tried this).
It seems like this will be a recurring issue more generally, not just for StrongSkipping
but for any arg implemented in new Compose versions (and not yet handled by Studio). Arguably we should ignore all unrecognized command line options when running in the IDE? I'm not sure.
gh...@google.com <gh...@google.com> #4
By the way, we should file a bug for JetBrains (or send a PR) to ensure that exceptions from compiler plugins cannot bring down all syntax highlighting / analysis. Only the compiler plugin should be affected.
al...@gmail.com <al...@gmail.com> #5
Great insight!
I discovered that while working on my own compiler plugin to show errors in the IDE.
Would it be possible to bring even a workaround fix to the Nightly build?
Thank you in advance!
ja...@google.com <ja...@google.com> #6
I am preparing a patch for compose compiler plugin used by Studio. By the way, the exception is from
I met a weird Compose compiler plugin checker behavior when I added the option. I am debugging it now.
By the way, we should file a bug for JetBrains (or send a PR) to ensure that exceptions from compiler plugins cannot bring down all syntax highlighting / analysis. Only the compiler plugin should be affected.
I agree. Before directly talking to JB, I want to clarify how to handle the unknown option. I will get back after investigating it.
pa...@gmail.com <pa...@gmail.com> #7
If someone can't wait to get their hands dirty with IDEA K2 in AS K, and are not afraid of Gradle, here's a hackaround that makes K2 work in IDEA with the config described in OP:
This assumes you're using Gradle convention plugins of some form, e.g. includeBuild("gradle/plugins")
or includeBuild("build-logic")
or buildSrc
. Without conventions included build it's way more complicated to create a plugin with the same name.
In the convention plugin included build, i.e. where you have kotlin-dsl
or java-gradle-plugin
applied, add:
dependencies {
// You probably already have this, listing it just to make sure. Without this the code won't compile.
implementation("org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:2.0.0-RC3")
}
gradlePlugin {
plugins {
// https://issuetracker.google.com/issues/341233001
create("workaround341233001") {
id = "org.jetbrains.kotlin.plugin.compose"
implementationClass = "com.example.FilteredComposeCompilerGradleSubplugin"
}
}
}
This will override the official Compose plugin. This is required because of the hardcoded checks in org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.ComposePluginSuggestApplyChecker
, plugin with this exact ID must exist in the Project
.
Next create the implementation of the plugin which behaves like the official plugin, except the strongSkipping
option:
package com.example
import org.gradle.api.provider.Provider
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradleSubplugin
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
import javax.inject.Inject
open class FilteredComposeCompilerGradleSubplugin(
private val subplugin: ComposeCompilerGradleSubplugin,
) : KotlinCompilerPluginSupportPlugin by subplugin {
@Suppress("unused") // Used by Gradle plugin mechanism.
@Inject constructor(registry: ToolingModelBuilderRegistry)
: this(@Suppress("INVISIBLE_MEMBER" /*internal*/) ComposeCompilerGradleSubplugin(registry))
override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> =
subplugin.applyToCompilation(kotlinCompilation)
.map { list ->
if (System.getProperty("idea.sync.active", "false").toBooleanStrict()) {
list.filter { option -> option.key != "strongSkipping" }
} else {
list
}
}
}
Gradle Sync, restart Android Studio, and you should be good to go. Notice that if
, which keeps the strongSkipping
for normal CLI/CI builds.
Obviously, YMMV, don't do this at work, and good luck!
ja...@google.com <ja...@google.com> #8
I submitted my commits that fix this issue. Koala.2/AGP-8.6 C3
will not have this issue.
pa...@gmail.com <pa...@gmail.com> #9
Any chance for a backport in Koala.1/AGP-8.5 B3, considering this is an actual IDE incompatibility with a stable Kotlin version?
K2 is an IDEA Platform feature is stableKotlin 2.0.0 - Koala.1 (> 2023.3) should be released with latest stable Kotlin (see screenshot)
gh...@google.com <gh...@google.com> #10
Although the K2 compiler is stable, K2 in the IDE is still in alpha (both in IntelliJ and in Android Studio). We recommend using Studio Canary if you want to try out K2 in the IDE. Note, as far as I know, it should be fine to use the K2 compiler in Gradle while still using the K1 frontend in the IDE.
pa...@gmail.com <pa...@gmail.com> #11
That is true, it's alpha, but based on this issue, the bug is in AS beta code, which is more stable than K2 in IDEA; and you're planning to call it "stable" in a few weeks/months while still including this bug.
A little bit of background: I don't want to use Canary builds, because switching "that off" is way too complicated compared to the K2 toggle. I just want to trial Kotlin EAP only, not AS / AGP, to help give feedback on K2 in IDE in the coming 3 months while .20 is being prepared. I cannot do that, because of this issue for months. Anyways, I'll just use my hack above for now then.
al...@gmail.com <al...@gmail.com> #12
Thanks for fixing the issue!
I can finally, for the first time ever, see errors from a K2 Compiler Plugin being picked up by the K2 IDE Plugin in Android Studio! 🎉🎉🎉
This working on Android Studio Koala Nightly:
Build #AI-241.15989.150.2412.11873503, built on May 22, 2024
Registry:
- kotlin.k2.only.bundled.compiler.plugins.enabled=false
ja...@google.com <ja...@google.com> #13
Nice! Thank you for reporting this issue and testing my workaround!
an...@google.com <an...@google.com> #14
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Koala Feature Drop | 2024.1.2 Canary 3
- Android Gradle Plugin 8.6.0-alpha03
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
DESCRIBE THE ISSUE IN DETAIL:
Hello,
Applying the new Compose Plugin bundle with Kotlin 2.0.0-RC3 on a newly created project using Android Studio Koala 2024.1.1 Beta 2, Koala Feature Drop, or Koala Nightly crashes the K2 IDE Plugin. Hence, the "Analyzing" phase never finishes.
In the idea.log you can find the following crash:
STEPS TO REPRODUCE:
ATTACH SCREENSHOTS/RECORDINGS OF THE ISSUE - Done
ATTACH LOG FILES (Select Help > Show Log in Files, or Show Log in Finder on a Mac) - Done
I've also attached the project itself if that can help.
IMPORTANT: Please readhttps://developer.android.com/studio/report-bugs.html carefully and supply
all required information.
Studio Build: Android Studio Koala Feature Drop | 2024.1.2 Nightly 2024-05-16 Build #AI-241.15989.150.2412.11849204 Version of Gradle Plugin: 8.6.0-alpha01 Version of Gradle: 8.7 Version of Java: 17.0.10; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o. OS: Mac OS X 14.4.1 (23E224)
Thank you in advance!