title: Dagger 2 Named cannot be provided without a @Provides method
body: <p>Trying to grok Dagger 2 and having an issue with named providers. I have a simple setup as follows:</p>
  <pre><code>// Module
  @Module
  class AppModule(private val app: App) {
      @Provides @AppScope fun providesApp() = app
  
      @Provides @AppScope fun provideSharedPreferences(app: App) = PreferenceManager.getDefaultSharedPreferences(app)
  
      @Provides @AppScope @Named(&quot;Uri1&quot;) fun providesUri1() = Uri.Builder().scheme(&quot;https&quot;).authority(&quot;authory1&quot;).build()
  
      @Provides @AppScope @Named(&quot;Uri2&quot;) fun providesUri2() = Uri.Builder().scheme(&quot;https&quot;).authority(&quot;authory2&quot;).build()
  }
  
  // Component
  @AppScope
  @Component(modules = arrayOf(AppModule::class))
  interface AppComponent {
      fun inject(target: MainActivity)
  }
  
  // MainActivity
  @Inject @AppScope lateinit var preferences: SharedPreferences
  @Inject @AppScope @Named(&quot;Uri1&quot;) lateinit var uri1: Uri
  @Inject @AppScope @Named(&quot;Uri2&quot;) lateinit var uri2: Uri
  </code></pre>
  <p>When rebuilding my project I am given:</p>
  <pre><code>Error:Gradle: android.net.Uri cannot be provided without an @Provides- or @Produces-annotated method.
  </code></pre>
  <p>I don't understand why adding the Named qualifier doesn't work for me here. If I remove these I can get an instance of SharedPreferences without issue.</p>
  <p>Any insight into what I'm doing wrong would be appreciated!</p>
  <h3>EDIT:</h3>
  <p>Changes per suggestions with the same results as above.</p>
  <pre><code>// New module
  @Module
  class AppModule(private val app: App) {
      @Provides @AppScope fun providesApp() = app
  
      @Provides @AppScope fun provideSharedPreferences(app: App) = PreferenceManager.getDefaultSharedPreferences(app)
  
      @Provides @AppScope @Tag(&quot;Uri1&quot;) fun providesUri1(): Uri = Uri.Builder().scheme(&quot;https&quot;).authority(&quot;authority1&quot;).build()
  
      @Provides @AppScope @Tag(&quot;Uri2&quot;) fun providesUri2(): Uri = Uri.Builder().scheme(&quot;https&quot;).authority(&quot;authority2&quot;).build()
  }
  
  // Tag annotation
  @Qualifier
  @Retention(AnnotationRetention.RUNTIME)
  annotation class Tag(val tag: String = &quot;&quot;)
  
  // MainActivity
  @Inject @AppScope lateinit var preferences: SharedPreferences
  @Inject @AppScope @Tag(&quot;Uri1&quot;) lateinit var uri1: Uri
  @Inject @AppScope @Tag(&quot;Uri2&quot;) lateinit var uri2: Uri
  </code></pre>
  <p><a href="https://github.com/deadpixelsociety/sandbox" rel="noreferrer">Project Repo @ Github</a></p>