title: Kotlin Kodein NotFoundException: No binding found for bind<String>() with ?<Fragment>()
body: <p>I have a very simple set up. But I am unable to perform any networking within my the fragment that I am using <code>Kodein</code> in. </p>
  
  <p>The fragment inflates and handles all interaction but the networking layer dependency is somehow missing because I receive: <code>NotFoundException: No binding found for bind&lt;String&gt;() with ?&lt;Fragment&gt;()</code> every time I hit the button that validates the username/password on this LoginFragmnet.</p>
  
  <p>I don’t understand this error because my <code>Fragment</code> class doesn’t have any <code>String</code> in it’s args/constructor? Or even depend on a <code>String</code>.</p>
  
  <p><strong>My Application class:</strong></p>
  
  <pre><code>...
  override val kodein = Kodein.lazy {
      import(androidXModule(this@MyApplication))
      bind() from singleton { MyLoginApi(instance(), instance()) }
      bind&lt;LoginDataSource&gt;() with singleton { LoginService(instance()) }
      bind&lt;LoginRepository&gt;() with singleton { LoginRepositoryImpl(instance()) }
  }
  ...
  </code></pre>
  
  <p><strong>My API</strong></p>
  
  <pre><code>interface MyLoginApi {
  
      @POST("Account/Login")
      @FormUrlEncoded
      fun login(
          @Field("username") username: String,
          @Field("password") password: String,
          @Field("sessionType") sessionType: String
      ): Call&lt;BaseApiResponse&lt;Login&gt;&gt;
  
      @GET("Account/Logout")
      fun logout(
          @Query("token") token: String
      ): Call&lt;BaseApiResponse&lt;Any&gt;&gt;
  
      companion object {
          operator fun invoke(
              baseUrl: String,
              cache: Cache
          ): MyLoginApi {
  
              val okHttpClient = OkHttpClient.Builder()
                  .cache(cache)
                  .readTimeout(60, TimeUnit.SECONDS)
                  .connectTimeout(60, TimeUnit.SECONDS)
                  .build()
  
              return Retrofit.Builder()
                  .client(okHttpClient)
                  .baseUrl(baseUrl)
                  .addConverterFactory(JacksonConverterFactory.create())
                  .build()
                  .create(MyLoginApi::class.java)
          }
      }
  }
  </code></pre>
  
  <p><strong>LoginService (The Datasource)</strong></p>
  
  <pre><code>class LoginService(private val api: MyLoginApi) : LoginDataSource {
      private val bus = EventBus.getDefault()
  
      init {
          bus.register(this)
      }
  
      override fun requestLogin(username: String, password: String) {
          val call = api.login(username, password, "mobile")
          call.enqueue { result -&gt;
              when (result) {
                  is Result.Success -&gt; {
  
                      result.response.body()?.let {
                          bus.post(LoginResponse(it, username))
                      } ?: bus.post(LoginResponse(IOException("System Error!")))
  
                  }
                  is Result.Failure -&gt; {
                      bus.post(LoginResponse(IOException(result.error)))
                  }
              }
          }
  }
  </code></pre>
  
  <p><strong>An Abstract Fragment class:</strong></p>
  
  <pre><code>abstract class InjectionFragment : Fragment(), KodeinAware {
  
      final override val kodeinContext = kcontext&lt;Fragment&gt;(this)
      final override val kodein: Kodein by kodein()
  
      final override val kodeinTrigger: KodeinTrigger?
          get() = if (BuildConfig.DEBUG) KodeinTrigger() else super.kodeinTrigger
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
          kodeinTrigger?.trigger()
      }
  }
  </code></pre>
  
  <p>I know this scenario is very trivial, but I’m trying to do this as a test before integrating in the rest of the project. The <code>Fragment</code> displays, but for some reason once I try to do a data request it crashes with an error saying:</p>
  
  <pre><code>org.kodein.di.Kodein$NotFoundException: No binding found for bind&lt;String&gt;() with ?&lt;Fragment&gt;().? { ? }
  
  module ⁣androidModule {
  bind&lt;String&gt;(tag = "packageResourcePath") with contexted&lt;Context&gt;().provider { String }
  bind&lt;String&gt;(tag = "packageCodePath") with contexted&lt;Context&gt;().provider { String }
  bind&lt;String&gt;(tag = "packageName") with contexted&lt;Context&gt;().provider { String }
  }
  </code></pre>
  
  <p><strong>Update:</strong>
  When single stepping through my Fragment it the debugger says that the <code>Repository</code> is <em>"Lazy value not initialized yet.”</em></p>