@JvmStatic in @Module companion object is not supported
See original GitHub issueWith the release of 2.25.2
, @JvmStatic
is not needed anymore for the @Module object classes, however we still have to use them for the @Module companion objects
Current solution example for avoiding it from companion objects:
@Module(includes = [FooModule.Static::class])
abstract class FooModule {
@Binds
abstract fun providesFoo() : Foo
@Module
object Static{
@Provides
fun providesFooStatic() : FooStatic
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Dagger 2 static provider methods in kotlin - Stack Overflow
Now Dagger2 (version 2.26) support companion objects in @Module annotated classes in kotlin withthouh @Module and @JvmStatic annotations.
Read more >Method in companion object is not found when calling from ...
If you want something to be available as a static method from Java/Groovy/etc, you need to annotate it as @JvmStatic . Does this...
Read more >Best Practices Kotlin Dagger Module with @Binds ... - Reddit
I am working on a new project where I'm using Hilt and Kotlin. ... 2 of these ways include not using a companion...
Read more >[Solved]-Dagger 2 static provider methods in kotlin-kotlin
This is not directly possible but with two nested modules (as Omar Al Halabi ... Now Dagger2 (version 2.26) support companion objects in...
Read more >Java Calling Kotlin - CommonsWare
@JvmStatic. Whether you use @file:JvmName() or not, Java can call top-level Kotlin functions. When it comes to functions on a companion object, things...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Companion objects are now supported in 2.26.
That is a solution, but would be good to support
objects
too. We dont always want to have multiple coupled modules with different naming