android / codelab-android-dagger

Apache License 2.0
181 stars 157 forks source link

Step 7 Provide context #38

Open aidanmack opened 4 years ago

aidanmack commented 4 years ago

In step 7 it goes into detail about how to provide a context it tells us... The way to pass it in is with a Component Factory and using the @BindsInstance annotation.

If I build straight after this i get the error... android.content.Context cannot be provided without an @Provides-annotated method.

To fix this issue I annoted property in the class that context is used like so..

class SomeClass @Inject constructor( @ApplicationContext private val context: Context )

Shijilal commented 4 years ago

@aidanmack i think you are missing @Component.Factory annotation above the interface Factory. I too missed that and got the same error