I upgraded an Android project from 1.0.5-3 to 1.0.6 and it now fails to build the test project but still builds the main project.
The error is: Error:(6, 23) Unresolved reference: DaggerTestComponent
The file giving the error is:
package com.example.kotlindaggerunittest
class TestApplication : MyApplication() {
override fun buildDaggerGraph() {
myComponent = DaggerTestComponent.builder().build()
myComponent.inject(this)
}
}
The component is:
package com.example.kotlindaggerunittest
import dagger.Component
import javax.inject.Singleton
@Singleton
@Component(modules = arrayOf(TestModule::class))
interface TestComponent : MyComponent {
fun inject(myNonLifecycleClassTest: MyNonLifecycleClassTest)
}
The main application which works is:
package com.example.kotlindaggerunittest
import android.app.Application
open class MyApplication : Application() {
companion object {
lateinit var myComponent: MyComponent
}
override fun onCreate() {
buildDaggerGraph()
}
open fun buildDaggerGraph() {
myComponent = DaggerMyComponent.builder().build()
myComponent.inject(this)
}
fun component(): MyComponent {
return myComponent
}
}
The main component that is extended is:
package com.example.kotlindaggerunittest
import com.example.kotlindaggerunittest.analytics.ThirdPartyAnalyticsWrapper
import com.example.kotlindaggerunittest.analytics.ThirdPartyAnalyticsWrapperHolder
import dagger.Component
import javax.inject.Singleton
@Singleton
@Component(modules = arrayOf(MyModule::class))
interface MyComponent {
fun inject(myApplication: MyApplication)
fun inject(mainActivity: MainActivity)
fun inject(myNonLifecycleClass: MyNonLifecycleClass)
fun inject(thirdPartyAnalyticsWrapper: ThirdPartyAnalyticsWrapper)
fun inject(thirdPartyAnalyticsWrapperHolder: ThirdPartyAnalyticsWrapperHolder)
}
This is a minimal example project extracted from a large production project. I’m happy to send the whole example project.