https://kotlinlang.org logo
#compose
Title
# compose
s

Saiedmomen

07/23/2022, 1:17 PM
How can we enable compose metrics and
@Stable
inference in multiplatform modules with android soucesets? There are no composables in the module. I have tried adding the following to the
android
block but doesn't seem to work and metrics report isn't generated for the module I am following Chris Banes blogpost on the issue and reports are generated for the main app module
Copy code
android {    
    ...
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = libs.versions.compose.get()
    }
}
👀 2
a

Albert Chang

07/23/2022, 3:50 PM
The lines you are showing are applying compose compiler plugin again and have nothing to do with compiler metrics. Add the compiler arguments as shown in the blog post.
s

Saiedmomen

07/24/2022, 7:42 AM
I have added the arguments like the article and it is working for the app module. I run:
Copy code
./gradlew assembleRelease -Pappname.android.enableComposeCompilerReports=true --rerun-tasks
and the reports are generated for the app module in the
app/build/compose_metrics
directory. Even though the gradle task from the article that sets the compiler flags is for all subprojects, it is only working for the app module. Also inference isn't working as I see in the app module report but there is a chance that it might be because of some gotcha in the inference rules. I need the report to debug it.
a

Albert Chang

07/24/2022, 7:53 AM
Are you adding the arguments to the root
build.gradle
file? Looks like you are adding them to the
build.gradle
of app module.
s

Saiedmomen

07/24/2022, 7:54 AM
yes I'm adding it to the root
build.gradle
I will create a minimum working example later
z

Zoltan Demant

07/24/2022, 11:28 AM
Are you specifying different files for the output? It might be that each report overwrites the previous one?
s

Saiedmomen

07/24/2022, 2:04 PM
It should be created in a path relative to each module. The app module report is indeed created at
app/build/compose_metrics
so I expect the shared module report to be created at
shared/build/compose_metrics
a

Arkadii Ivanov

07/27/2022, 10:23 AM
Here is an example - https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp Also please note that compose doesn't officially support iOS yet.
a

Albert Chang

07/27/2022, 10:28 AM
You are using multiplatform plugin in the shared module so you should apply jetbrains compose plugin. I’m not sure whether AGP’s feature to apply compose compiler plugin works well with kotlin multiplatform plugin.
s

Saiedmomen

07/27/2022, 11:34 AM
@Albert Chang yeah it seems to have issues at the moment
l

Landry Norris

07/27/2022, 1:55 PM
When you say multiplatform, do you mean Android/desktop, or Android/iOS?
s

Saiedmomen

07/27/2022, 1:57 PM
android/iOS but doesn't work even for class specific to android sourceset
176 Views