jewel icon indicating copy to clipboard operation
jewel copied to clipboard

How to create an Android Studio plugin with Jewel?

Open mr-thierry opened this issue 11 months ago • 15 comments

If I set this:

intellij {
   ....
    plugins.set(listOf("android"))
}

Apparently Android Studio has Jewel v0.11 already bundled (I'm targeting Android Studio Iguana | 2023.2.1 Patch 1). When I run a simple plugin, I have the following error:

Caused by: java.lang.IllegalStateException: Can't add together different TextUnits. Got Unspecified and Sp
	at org.jetbrains.jewel.ui.component.TypographyKt.plus-NB67dxo(Typography.kt:76)
	at org.jetbrains.jewel.ui.component.Typography.h3TextStyle(Typography.kt:60)

Looking at the Gradle dependencies, I see that unzipped.com.jetbrains.plugins:android:unzipped.com.jetbrains.plugins:android-studio-AI-232.10300.40.2321.11567975 had the jewel-ui-0.11.0.jar dependency.

This conflicts with my project settings.

mr-thierry avatar Mar 21 '24 14:03 mr-thierry

Android Studio is not currently supported — I don't think it's supposed to ship Jewel yet, but there are some features we're working on that will use Jewel, so it may just be getting ready in advance.

To target Android Studio you currently would need to jarjar/shadow Compose and Jewel.

rock3r avatar Mar 21 '24 14:03 rock3r

You can look at how Package Search does it — their plugin works fine in Android Studio afaik.

rock3r avatar Mar 21 '24 14:03 rock3r

Also found this: https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/587

mr-thierry avatar Mar 21 '24 15:03 mr-thierry

Android Studio is not currently supported — I don't think it's supposed to ship Jewel yet, but there are some features we're working on that will use Jewel, so it may just be getting ready in advance.

To target Android Studio you currently would need to jarjar/shadow Compose and Jewel.

Would it be possible to put that IN ALL CAPS AND WITH A BIG FONT SIZE in the README? 🙂 (that would have avoid me wasting a day of development)

Especially since the video in the README file is from a Droidcon talk. 😉

mr-thierry avatar Mar 21 '24 15:03 mr-thierry

Would it be possible to put that IN ALL CAPS AND WITH A BIG FONT SIZE in the README? 🙂 That's a very reasonable request :) Sorry, I hadn't thought of it before.

To be honest, I hope we'll manage to figure out a way to avoid leaking the Jewel/Compose dependency for Studio 3p plugins. I'll see if my colleagues can find a way! Dependencies are pretty complicated beasts in the IntelliJ Platform when you look at them from the 3p plugin perspective 😓

rock3r avatar Mar 21 '24 15:03 rock3r

Reopened to remind me to add that notice to the readme, and hopefully to fix things in Studio dependencies so that Jewel doesn't leak to 3p plugins

rock3r avatar Mar 21 '24 15:03 rock3r

I have filed an issue against Studio to try and sort out this dependency leak. @mr-thierry does this happen on Jellyfish, too? I would expect so, since the setup is the same.

rock3r avatar Mar 21 '24 15:03 rock3r

@mr-thierry does this happen on Jellyfish, too? I would expect so, since the setup is the same.

Tried with Jellyfish 2023.3.2.1 and it has the same issue

mr-thierry avatar Mar 21 '24 16:03 mr-thierry

Thanks for confirming!

rock3r avatar Mar 21 '24 16:03 rock3r

You can look at how Package Search does it — their plugin works fine in Android Studio afaik.

I have download and ran the project. This project targets IntelliJ and not Android Studio. I does add a dependency to the Android Gradle plugin however. That may be enough for what I'm looking to do. Thanks for the suggestion!

mr-thierry avatar Mar 21 '24 17:03 mr-thierry

Yeah, PKGS does target IJ but works fine in Studio (or used to! haven't checked in Studio in a while). They have the shadowing because the IJ platform at some point had a copy of Compose that was leaking, too, and that made it work, so I think it should indeed work for Studio until this is properly sorted

rock3r avatar Mar 21 '24 17:03 rock3r

Follow-up on this for anyone looking for a solution to this issue: I ended up using the Jewel component that is currently shipping with Android Studio. While the version is quite old (v0.11), it's still better than using Swing IMHO 🙂

mr-thierry avatar Mar 22 '24 12:03 mr-thierry

I have added a note in the readme mentioning this. https://github.com/JetBrains/jewel/blob/main/README.md#branching-strategy-and-ij-platforms

Will update when there are news on the Studio side.

rock3r avatar Mar 22 '24 14:03 rock3r

Do you have a link to the issue? Will +1 it 🙂

mr-thierry avatar Mar 22 '24 17:03 mr-thierry

Unfortunately there is no public component yet since we haven't shipped the feature yet... So it's private for now :(

But the right people is aware!

rock3r avatar Mar 22 '24 18:03 rock3r

This will need to be solved at the IJP level (hopefully in 243). Closing, since work has moved on their side.

rock3r avatar Aug 12 '24 13:08 rock3r