title: How do you inject impl of some interface in an Android Activity using Guice
body: <p>I'm using Guice 3.0 on Android to do some DI. </p>
  
  <p>I have</p>
  
  <pre><code>public interface APIClient { }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class DefaultAPIClient implements APIClient { }
  </code></pre>
  
  <p>What I did was try to bootstrap Guice in my MyApplication class giving it a module that has one statement in the configure method <code>bind(APIClient.class).to(DefaultAPIClient.class);</code></p>
  
  <p>I did what the Guice example told me to do</p>
  
  <pre><code>Injector injector = Guice.createInjector(new APIClientModule());
  injector.getInstance(APIClient.class);
  </code></pre>
  
  <p>I may not be understanding this correctly, but how would I go about injecting APIClient into several Activities that will use it? </p>
  
  <p>I did this in <code>HomeActivity</code></p>
  
  <pre><code>public class HomeActivity extends RoboActivity {
      @Inject APIClient client;
  
      protected void onCreate(Bundle savedInstanceState) {
          client.doSomething();
      }
  }
  </code></pre>
  
  <p>This doesn't work and it gives me the <code>Guice configuration errors: 1) No implementation for com.mycompany.APIClient was bound</code></p>
  
  <p>So the only way I was able to get this to work was to remove the <code>@Inject</code> from the APIClient client in HomeActivity and inject it using <code>client = Guice.createInjector(new APIClientModule()).getInstance(APIClient.class);</code></p>
  
  <p>So does this mean that I'll have to do this in every Activity that uses APIClient? I must be doing something wrong.</p>
  
  <p>Any help would be great. Thanks!</p>