Does anyone know of what jetbrains compose gradle ...
# compose
c
Does anyone know of what jetbrains compose gradle plugin actually does? I'd like to use jetbrains compose instead of jetpack compose in my android project (mostly so that it's easier to sync compose versions across my other modules which will actually need to be jetbrains compose). But im having issues converting my android app module to use jetbrains compose.
For example, if I just take the plugin and apply it to my project, I get complaints about a version mismatch. So I remove my declaration of
Copy code
composeOptions { kotlinCompilerExtensionVersion = composeCompilerVersion }
but now i get another error of compose compiler 1.3.2 which i dont have declared anywhere. I copied my toml straight from kmp.jetbrains.com so all of my versions should work just fine as the sample works fine. e: This version (1.3.2) of the Compose Compiler requires Kotlin version 1.7.20 but you appear to be using Kotlin version 1.9.21 which is not known to be compatible. Please fix your configuration (or
suppressKotlinVersionCompatibilityCheck
but don't say I didn't warn you!).
s
You need to add that composeOptions block back in android build.gradle and make sure composeCompilerVersion is atleast 1.5.6 in toml file to support kotlin 1.9.21 Then try cleaning build or may be invalidate cache and rebuild
e
the jetbrains compose plugin doesn't configure an android-specific project. that 1.3.2 is coming from AGP's old defaults and needs to be overridden
đź‘€ 1
c
Alright. so i have a plain ol android app with compose already. these are the plugins at the top of the app file
Copy code
plugins {
  id("com.android.application")
  id("org.jetbrains.kotlin.android")
  id("com.google.firebase.crashlytics")
  id("com.google.gms.google-services")
  id("com.google.firebase.firebase-perf")
}
I'm going to go ahead and add alias(libs.plugins.jetbrainsCompose) then update composeCompilerVersion to also pull from the toml (the toml that was generated from kmp.jetbrains.com)
e
note that the jetbrains compose compiler plugin and the androidx compose compiler plugin don't quite have the same versioning or compiler compatibilities…
c
updated composeOptions to the below
Copy code
composeOptions { kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get() }
@ephemient gotcha. yeah at this point its just like. i have a plain ol android app. and another "design system" module, also android. so now i want to move over to jetbrains compose for both modules. and then i want to move design system to be kmp.
but ive been stuck on this for like 2 days. and im like "im definitely missing something fundamental here".
do I still need
Copy code
buildFeatures { compose = true }
if i use jetbrains compose?
e
I believe you still do
c
no freakin way. the app actually launched. 🤦
crashed immediately. but thats further than ive ever gotten
lol
e
in one of my projects I have (the equivalent of)
Copy code
configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute(module(libs.androidx.compose.compiler.get().toString()))
            .using(module(libs.jetbrains.compose.compiler.get().toString()))
    }
}
to make an Android project use the JetBrains compiler plugin
c
oh weird. ran it again. no crash
e
but really it should be fine to use the AndroidX compiler plugin in one module and the JetBrains compiler plugin in another
they just might not have the same version number
c
gotcha. yeah i was hoping to basically have all the version numbers in line so using just one compiler plugin seems fine to me.
feel like just keeping tabs on one set of versions is easier for my sanity. lol
e
also vice versa, the androidx compiler plugin can be used in KMM modules too
c
weird that i was trying to base my project off of samples online, but like this sample https://github.com/JetBrains/compose-multiplatform/blob/master/examples/chat/androidApp/build.gradle.kts does not have
Copy code
composeOptions { kotlinCompilerExtensionVersion = ...
so i just thought the jetbrains compose plugin enables compose and sets up the compiler (due to what the samples have me believe. lol)
e
so that's a KMM module, just with a single Android target
the JB compose gradle plugin applies there. that's different than applying to a pure Android module
c
gotcha. okay. so i figured the alias(libs.plugins.kotlinMultiplatform) had something to do with my issue.
but cool. now that im using jetbrains compose for all of my modules (technically 3 modules that we have). i will move onto my next step of keeping my android app module android, but ill move my other two modules to kmp.
FWIW, my idea was that hopefully have an android app of like version 1.6 of jetpack compose wouldn't somehow not work with our kmp design system module that uses jetbrains compose 1.5 or something. seems like that's not a worry i need to have? but anyway. i think everything using the toml and all the versions in the toml should work out pretty well.
150 Views