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

The function Module.define<*> is overwritten in a multi-module project #201

Open
AndreiChesnokov1994 opened this issue Dec 23, 2024 · 0 comments

Comments

@AndreiChesnokov1994
Copy link

Describe the bug
A multi-module project run with an error when using classes with the same name.

To Reproduce
Module 1

package testproject.test1

@Single
class Test{}

@Single
class Test1(val test: Test)

Module 2

package testproject.test2

@Single
class Test{}

@Single
class Test2(val test: Test)

Module Main

package testproject

@ComponentScan("testproject")
class AppModule

class MainActivity : AppCompatActivity() {
    private val test1: Test1 by get()
    private val test2: Test2 by get()
    ...
}

Result. Project run with error
Caused by: org.koin.core.error.NoDefinitionFoundException: No definition found for type 'testproject.test2.Test'

This happens because the define<*> functions are added to the generated AppModule class without regard to the package name.

package org.koin.ksp.generated

AppModule = module {
  defineTest()
  defineTest1()
  defineTest()
  defineTest2()
}

Since there are two defineTest() functions, only the first one resolves.

Expected behavior
Run the project without errors

Koin project used and used version:
koin = "4.0.1-RC1"
koin-annotations = "2.0.0-Beta2" or "1.4.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant