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

Compile check with multi module setup. #103

Open
extmkv opened this issue Nov 30, 2023 · 12 comments
Open

Compile check with multi module setup. #103

extmkv opened this issue Nov 30, 2023 · 12 comments
Labels
question Further information is requested status:checking Ticket is currently being checked type:issue Something isn't working

Comments

@extmkv
Copy link

extmkv commented Nov 30, 2023

Describe the bug
Our project has 90+ modules, where 38 use Koin. After finishing the migration to Koin Annotations, we enabled the flag in all modules, and an issue arises when a module requires a dependency provided in another one, causing it to fail.

To Reproduce
Lets take into consideration a project with 3 library modules + 1 app module.

  • Module A: Domain module
  • Module B: Implements some interfaces from Module A and register on Koin
  • Module C: It's a feature an needs to get some stuff from Koin.

Module A
This module contains an interface Foo.

Module B
Has an implementation of Foo called Bar

@Single
internal fun provideFoobar() : Foo {
     return Bar()
}

Module C

@Factory
internal fun provideMyFactory(
    foo: Foo
) : MyFactoryObject {
     return MyFactory.build(too)
}

App

 startKoin {
            androidLogger(Level.ERROR)
            androidContext(this@TrilogyApp)
            modules(listOf(ModuleA().module, ModuleB().module))
        }

Error

e: [ksp] --> Missing Definition type 'com.example.Foo' for 'com.example.b.provideMyFactory'. Fix your configuration to define type 'Foo'.

I'm gonna create a repository with a similar setup.

@rodrirepresa
Copy link

Here is a repo to reproduce @extmkv issue:
https://github.com/rodrirepresa/koinannotationissue

@extmkv
Copy link
Author

extmkv commented Jan 9, 2024

@arnaudgiuliani do you have any insights or idea how we can solve this?

@TheReprator
Copy link

TheReprator commented Jan 17, 2024

One way is to create a dependency graph from there like we do with hilt or dagger, and remove the annotation from the class, it will work, bcz i had faced the issue, and was able to sort in this way, so i hope, it will get sorted, and this is a bug obviously

@extmkv
Copy link
Author

extmkv commented Jan 17, 2024

@TheReprator can you provide an example?

@TheReprator
Copy link

TheReprator commented Jan 17, 2024

I don't know, whether it helped or not, You can see this repo, for this use case,

Repository: https://github.com/TheReprator/AccountBook_Backend/tree/koinAnnotation
Branch: koinAnnotation

More specifically, like this, https://github.com/TheReprator/AccountBook_Backend/blob/koinAnnotation/api/userIdentity/src/main/kotlin/dev/reprator/userIdentity/di/UserIdentityModule.kt

But you will not be able to run this, as it have a dependency which I need to provide dynamically, and I had raised a bug in koin for that,

Regards,
Vikram Singh

@arnaudgiuliani
Copy link
Member

arnaudgiuliani commented Jan 30, 2024

sorry for the delay 🙏

@extmkv did you use includes to be sure you chain the modules?

C uses B uses A. Then you need to include A in B, and B in C.

@arnaudgiuliani arnaudgiuliani added the question Further information is requested label Jan 30, 2024
@ZackOPP
Copy link

ZackOPP commented Feb 6, 2024

C uses B uses A. Then you need to include A in B, and B in C.

I have the same issue. Using include doesn't work for me, I still get the issue about the missing dependency.

@extmkv
Copy link
Author

extmkv commented Feb 12, 2024

@arnaudgiuliani I don't think that will work at all. Did you had time to check the repository shared by @rodrirepresa ?

@arnaudgiuliani arnaudgiuliani added type:issue Something isn't working status:checking Ticket is currently being checked labels Feb 15, 2024
@arnaudgiuliani
Copy link
Member

Ok, need to check more deeply 👍

@extmkv
Copy link
Author

extmkv commented Jul 19, 2024

@arnaudgiuliani did you manage to have a look?

@krzdabrowski
Copy link

@arnaudgiuliani any updates on this? This issue still occurs on KA 1.4.0/2.0.0-Beta1 between two feature modules

@BraveOwlet
Copy link

@arnaudgiuliani Is there a way to fix it?
I also have this problem on KA 1.4.0/2.0.0-Beta1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested status:checking Ticket is currently being checked type:issue Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants