https://kotlinlang.org logo
#decompose
Title
# decompose
l

Landry Norris

06/02/2022, 6:52 PM
I recently ran into this error when running compileIosMainKotlinMetadata
Copy code
Cannot access 'com.arkivanov.decompose.ComponentContext' which is a supertype of 'com.example.myapp.component.TrimComponent'. Check your module classpath for missing or conflicting dependencies
The normal build process runs just fine, there’s no errors showing up in the IDE, and the app works, but I can’t publish my library because maven-publish tasks rely on the metadata task. I have some parts of the app set up as a library that the main app pulls in.
This error shows up for every usage of my TrimComponent class. As of now, this is my only Component.
a

Arkadii Ivanov

06/02/2022, 7:07 PM
It looks like your module depends on another module containing
TrimComponent
. You should also add
decompose
as a dependency.
l

Landry Norris

06/02/2022, 7:27 PM
I have this line in the commonMain dependencies block of my build.gradle.kts
Copy code
implementation("com.arkivanov.decompose:decompose:0.6.0")
a

Arkadii Ivanov

06/02/2022, 7:36 PM
Without a reproducer it's hard to say what is wrong exactly. But in general that error says that Decompose is a transitive dependency there and ComponentContext can't be accessed.
l

Landry Norris

06/02/2022, 7:40 PM
I’ll look into making a repro over the weekend.
👍 1
This project has few modules, so TrimComponent is directly part of the module that failed. I’m hoping that I just set something up wrong in my build.gradle.kts
a

Arkadii Ivanov

06/02/2022, 7:43 PM
Thanks!
l

Landry Norris

06/06/2022, 2:08 PM
I was unable to reproduce the issue on a smaller project. I’ve checked my build gradle and confirmed that decompose is listed as a dependency in commonMain of the modules that use it. The app compiles and runs fine. It’s just this metadata task that’s failing.
a

Arkadii Ivanov

06/06/2022, 2:11 PM
What Kotlin version are you using?
So far I have found a similar issue - https://github.com/cashapp/sqldelight/issues/2590 It's not clear yet what was the solution, but I suspect there might be some issues with HMPP. Decompose depends on Kotlin 1.6.10 so far and HMPP is disabled for now. I will double check if there is anything wrong.
l

Landry Norris

06/06/2022, 4:00 PM
I’m using 1.6.21 and for Compose, I’m using compose-jb 1.2.0-alpha01-dev686
a

Arkadii Ivanov

06/06/2022, 4:03 PM
That might be an issue. I remember something like they changed the metadata format recently.
Is there any reason why you need the unstable Compose version? Maybe you could downgrade to 1.6.10 and 1.1.1 respectively?
Even though it is recommended to use stable versions, but if you really need Compose
1.2.0-x
, then you can try Decompose version 0.6.0-native-compose-01 - https://github.com/arkivanov/Decompose/releases/tag/0.6.0-native-compose-01 This version uses Kotlin 1.6.21 and Compose
1.2.0-alpha01-dev675
. It experimentally supports the new iOS and macOS native targets. But if you don't use them, this shouldn't bother you.
l

Landry Norris

06/06/2022, 4:53 PM
I’m on the experimental versions so I can add iOS support easily once compose for iOS is more stable. I can look into downgrading to 1.1.1 for now and upgrade later.
a

Arkadii Ivanov

06/06/2022, 6:13 PM
Yeah! Compose for iOS is not quite ready yet.
l

Landry Norris

06/17/2022, 4:25 PM
I finally got the chance to focus on fixing this issue in the app (We recently had a release for the app and it’s ben keeping me busy lately). It looks like switching to 0.6.0-native-compose01 with compose dev675 resolved the issue. I can now publish without having to manually run the last few publications after the ios fails.
K 1
s

Shabinder Singh

09/19/2023, 8:12 AM
https://github.com/icerockdev/moko-parcelize/issues/41 Related, also happens when using essenty parcelable, and event tried publishing my own, IDE shows red error, but build always work
Copy code
Cannot access 'in.shabinder.soundbound.parcelize.Parcelable' which is a supertype of 'in.shabinder.soundbound.models.SongModel'. Check your module classpath for missing or conflicting dependencies.
another interesting thing is, the red highlight only comes in
androidMain
, other source sets work fine without any ide error, and build also works. • If I remove library dependency in commonMain, and add in androidMain instead, error disappears from androidMain, but commonMain then obviously cant resolve and build fails. lmk if I can provide any more details or any helpful info on same, this has been quite annoying since most of code in androidMain accessing model shows error, but works just fine.
a

Arkadii Ivanov

09/19/2023, 8:24 AM
Those errors are most likely KMP issues. Feel free to file a bug on YouTrack.
On androidMain you can try using Parcelable/Parcelize from Android, not from Essenty.
s

Shabinder Singh

09/19/2023, 8:29 AM
So, My SongModel resides in commonMain in library artifact which extends parcelable. Now I have mainProject • Module : Extension (kmp module) ◦ api dependency on libNo issues or errors here even in android main • Module: Shared (another kmp module) ◦ implementation dependency on project extension. ◦ This gives error
a

Arkadii Ivanov

09/19/2023, 8:38 AM
I think you also need to add Essenty as a dependency for the second module. And apply kotlin-parcelize plugin there as well.
s

Shabinder Singh

09/19/2023, 8:39 AM
have done both already
a

Arkadii Ivanov

09/19/2023, 8:39 AM
Does the project compile?
s

Shabinder Singh

09/19/2023, 8:41 AM
yes compile and builds fine. • another interesting thing, even if i remove in shared module dependency on project extension. • and use dependency on lib directly, error's still there. So something with shared module I suppose. but below somehow fixes the conflict atleast for androidMain, but then I cant builds
If I remove library dependency in commonMain, and add in androidMain instead, error disappears from androidMain, but commonMain then obviously cant resolve and build fails.
a

Arkadii Ivanov

09/19/2023, 8:42 AM
If the project compiles, and you are sure that you have added Essenty
parcelable
module as a dependency in your Shared module, then this must be an issue with KMP/IDE.
Also maybe try aligning versions of Decompose and Essenty. I.e. use the same Essenty version that is used by the version of Decompose.
Update Kotlin version, etc. 🙂 I don't think there is anything we could do at the library level.
s

Shabinder Singh

09/19/2023, 8:44 AM
but it should have worked when I use moko-parcelize or my custom lib, if was versioning conflict. I believe too, its IDE issue, will see if I can build a minimal reproducer.
a

Arkadii Ivanov

09/19/2023, 8:44 AM
Essenty Parcelize shound't be compatible with Moko parcelize in commonMain
s

Shabinder Singh

09/19/2023, 8:45 AM
Yes, I meant not using essenty parcelize and instead using moko in all, and using my own in all.
a

Arkadii Ivanov

09/19/2023, 8:46 AM
You can try updating Kotlin and/or IDE (including Kotlin IDEA plugin) to the latest versions
s

Shabinder Singh

09/19/2023, 8:47 AM
will do and report back. thanks for the info.
👍 1
IDE and plugin updates didnt fixed this. Found this, seems exactly what I am facing: https://youtrack.jetbrains.com/issue/KTIJ-10861/
a

Arkadii Ivanov

09/19/2023, 12:48 PM
Looking at the description of the issue, it looks a bit different. There they have: "lib is a binary dependency included into the project as a library, it has compile time dependency on module1", where "module1 is a module in the project". But in your case, I think
lib
is Essenty and it doesn't depend on any of your project modules.
👀 1
s

Shabinder Singh

09/26/2023, 8:16 AM
Update in here: • A nice side-effect of migrating to serializable is, above doesn't come anymore in my IDE. Finally clean looking project files to work with, no more false red-highlights.
👍 1
🎉 1
10 Views