Is there any known issues with using material3 wit...
# compose
h
Is there any known issues with using material3 with Compose Multiplatform on desktop (
jvm("desktop")
)?
Ok, so I found the issue I was having. I'm getting the following error now:
Copy code
Suppressed: java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used
As far as I know, I'm not including
coroutines-android
myself. Any usual suspect that might be including it?
a
Have you tried checking the output of
./gradlew app:dependencies
(or similar according to your project-structure)? I don't know about CMP, but this is what I usually do in an android-project in such a case.
I just did check in my android-app. Do you depend on
org.jetbrains.kotlinx:kotlinx-coroutines-bom
directly or indirectly? It might get pulled in by
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm
according to my dependency-tree:
Copy code
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 -> 1.10.1
 \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1
      +--- org.jetbrains:annotations:23.0.0
      +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.1
      |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1 (c)
      |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1 (c)
      |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1 (c)
      |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.10.1 (c)
      |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1 (c)
      |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.1 (c)
This seems like a dependency-bug in the BOM to me.
h
I only depend on it indirectly
a
Ah, might not be a bug, the
(c)
behind it marks just a constraint in the BOM, it might not mean it is pulling the actual dependency in, if I understand it correctly.
h
Any way to exclude as a workaround for now? I'm not a gradle expert 🙂
a
I am just guessing, but maybe something like this:
Copy code
configurations {
  runtime.exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-android"
}
This is discussed here: https://stackoverflow.com/questions/21764128/how-do-i-exclude-all-instances-of-a-transitive-dependency-when-using-gradle
h
YEah, that doesn't work in multiplatform
a
If you are using Android Studio, using the Dependency Analyzer from the Gradle tool-window might give some more insights, as it is able to list all dep-tree-slices that depend on a given dependency...
Other than that, I guess you would have to comment out one after another of your dependencies (and related code) and see which dependency causes the problem.
For me, coroutines-android is depended on by many dependencies, like • paging-runtime • window • lifecycle-runtime-android • lifecycle-viewmodel-* • runtime-android (from lifecycle-runtime-compose-android) • coil-base • room-ktx • accompanist
p
Can you share the Gradle file or part of it. Ensure you are not placing an Android library in common main, happens often especially because many of the Android libraries have a JetBrains equivalent, you need to make sure you are placing the JetBrains not the Android-only dependency.
h
@Pablichjenkov I have LOTS of modules. As far as I can tell, none of the declared dependencies are Android specific libraries. I think this is a transitive dependency problem and it only occurs for the jvm target. The iOS targets works fine
p
I see, well in such a case you could git bifurcate to see the commit that introduced the dependency. Is the only thing that comes to my mind.
1
a
I think he is talking about
git bisect
. You go back in your git-history, mark a specific git-commit as working, and the head-commit as bad, and then it does a binary search to find the breaking commit.
h
I have a single commit where I enabled
jvm("desktop")
. git bisect doesn't really help here
p
Right, I was talking about that. Ouch 😓, well good luck finding the culprit
a
@hellman did you try the approaches I gave you with the Dependency Analyzer and with the out-commenting dependencies?
h
@Arne Jans Yeah, I tried to adapt it for desktopMain sources, but it didn't work