Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KoinDefIoKtorClientHttpClient class in multiple KoinMeta's when exporting and using multiple modules #186

Open
rschattauer opened this issue Nov 12, 2024 · 0 comments
Labels
type:issue Something isn't working
Milestone

Comments

@rschattauer
Copy link

Describe the bug
Kind of like the same issue as #178 , but I wanted to create a new issue as it may be a little bit different.
I have multiple modules that are all using (for example) Ktor and I build all of them and upload them to Nexus. Once building my Android application it fails with "Duplicate class" for KoinDefIoKtorClientHttpClient.

To Reproduce
My KMP part is using multiple modules that are all build and exported to our Nexus. Meaning on nexus I have my.stuff:module-a:1.0.0 and my.stuff:module-b:1.0.0 which both have an http client that do different things.

Building and uploading to nexus is no issue, but using it within my android application I get the following error

Execution failed for task ':app:checkLongtermStageDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
     Duplicate class org.koin.ksp.generated.KoinDefIoKtorClientHttpClient found in the following modules: module-a-1.0.0-SNAPSHOT.aar -> module-a-1.0.0-SNAPSHOT-runtime (my.stuff:module-a:1.0.0-SNAPSHOT:20241112.085747-4), and module-b-1.0.0-SNAPSHOT.aar -> module-b-1.0.0-SNAPSHOT-runtime (my.stuff:module-b:1.0.0-SNAPSHOT:20241112.085747-4)

Ktor http client is just one example, I am facing this issue with all things that are generated using annotations.
For example also public class KoinDefKotlinxSerializationJsonJson

My modules look like this:

@org.koin.core.annotation.Module
@org.koin.core.annotation.ComponentScan
internal object ModuleA

&

@org.koin.core.annotation.Module
@org.koin.core.annotation.ComponentScan
internal object ModuleB

, so nothing fancy or even special.

My httpClient definition for both modules look kind of like

@Single
@Named("ModuleA.HttpClient")
fun moduleAHttpClient(): HttpClient = createHttpClient(..)

Making the definitions internal doesn't resolve this problem, I am still facing multiple creations.

Expected behavior
Maybe the package also needs to be applied for third party classes/dependencies?

Koin project used and used version:
Koin Annotation 1.4.0 & 2.0.0-Beta01

@arnaudgiuliani arnaudgiuliani added this to the 2.0 milestone Nov 15, 2024
@arnaudgiuliani arnaudgiuliani added the type:issue Something isn't working label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:issue Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants