Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Android Preview #18

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

dima-avdeev-jb
Copy link
Contributor

@dima-avdeev-jb dima-avdeev-jb commented Aug 21, 2023

Resolves Issue JetBrains/compose-multiplatform#3499
And workaroung Issue JetBrains/compose-multiplatform#3531

Added Android Preview in shared module

image
  • Also need to open the same PR in ios-android-template too

compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe move Compose compiler version to gradle.properties?
Or even reuse Compose Multilatform Compiler?

Copy link
Collaborator

Choose a reason for hiding this comment

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

even reuse Compose Multilatform Compiler?

the versions usually don't match, we can't reuse them

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, there are issues when we add this to our template:

  1. we apply 2 Compose compiler plugins (androidx one, and jetbrains one). It is not obvious, which will be applied
  2. the jetbrains Gradle plugin applies compiler plugin depending on the Kotlin version. If we downgrade Kotlin to 1.8.21, the Gradle plugin will apply jetbrains compose compiler 1.4.*, but because the android compiler is hardcoded now, android won't compile
  3. it adds an additional action when we need to update templates - we should map the compilers and add an appropriate version.

So, we can't officially recommend this approach yet. Only as a workaround if users need this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Possible reliable solutions:

  1. add an internal mapping Kotlin -> androidx compiler, and apply buildFeatures + composeOptions implicitly in the Gradle plugin
  2. exclude applying androidx compiler somehow, and always apply jetbrains compiler

Both require changes in our Gradle plugin

Copy link
Collaborator

@eymar eymar Aug 24, 2023

Choose a reason for hiding this comment

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

Do other target work with this change? I'm wondering if different compose compiler plugins don't mixup.

Or even reuse Compose Multilatform Compiler?

Ideally, Compose Multilatform Compiler should work for anroid too. I'm just not sure if we can configure it in android.composeOptions....

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally, Compose Multilatform Compiler should work for anroid too

I even say - must work, and it is how it works for Android now.

@senk0n
Copy link

senk0n commented Aug 29, 2023

Usage of androidx compose compiler also enables us to use AS Layout Inspector for Compose Multiplatform composables written in common code.
Also, you have to make sure you don't exclude all the meta-data so AS plugin can check the version of compose is used in app.

I noticed this after bumping Kotlin version to 1.9.0 and compose mp 1.5.0-beta01, before that, it wasn't possible for me. You can test it in this version of my repo. (those one, two commits initially helped me, essentially the same what you did in this PR)

Thus, maybe we can change the name of this PR, so people know it's possible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants