How can we enable compose metrics and `@Stable` i...
# compose
s
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
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
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
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
yes I'm adding it to the root
build.gradle
I will create a minimum working example later
z
Are you specifying different files for the output? It might be that each report overwrites the previous one?
s
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
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
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
@Albert Chang yeah it seems to have issues at the moment
l
When you say multiplatform, do you mean Android/desktop, or Android/iOS?
s
android/iOS but doesn't work even for class specific to android sourceset
237 Views