title: dagger2 injection not working - SharedPreferences
body: <p>I am trying my hands on Dependancy Injection using <a href="http://google.github.io/dagger/" rel="noreferrer">Dagger2</a>.
  It gives error in build phase and says cannot inject SharedPreference instance.</p>
  
  <p>Here are my modules and components.</p>
  
  <p><code>Application Module</code></p>
  
  <pre><code>@Module
  public class ApplicationModule {
      private Application app;
      private String PREF_NAME = "prefs";
  
      public ApplicationModule(Application app) {
          this.app = app;
      }
  
      @Singleton
      @Provides
      public Picasso getPicasso() {
          return new Picasso.Builder(app).build();
      }
  
      @Singleton
      @Provides
      public SharedPreferences getAppPreferences() {
          return app.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
      }
  }
  </code></pre>
  
  <p><code>ApplicationComponent</code></p>
  
  <pre><code>@Component(modules = {ApplicationModule.class})
  public interface ApplicationComponent {
      void inject(App app);
  }
  </code></pre>
  
  <p><code>App.java</code></p>
  
  <pre><code>public class App extends Application {
  
      ApplicationComponent appComponent;
  
      @Override
      public void onCreate() {
          super.onCreate();
          createDaggerInjections();
      }
  
      public ApplicationComponent getAppComponent() {
          return appComponent;
      }
  
      public static App getAppInstance(Context context) {
          return (App) context.getApplicationContext();
      }
  
      private void createDaggerInjections() {
  
          appComponent = DaggerApplicationComponent.builder()
                  .applicationModule(new ApplicationModule(this))
                  .build();
          appComponent.inject(this);
  
      }
  }
  </code></pre>
  
  <p><code>Login Module</code></p>
  
  <pre><code>@Module
  public class LoginModule {
  
      LoginView view;
  
      public LoginModule(LoginView view) {
          this.view = view;
      }
  
      @Provides LoginView getLoginView()
      {
          return view;
      }
  
      @Provides LoginPresenter getLoginPresenter(LoginView view)
      {
          return new LoginPresenterImpl(view);
      }
  
  }
  </code></pre>
  
  <p><code>LoginComponent</code></p>
  
  <pre><code>@ActivityScope
  @Component(
          dependencies = ApplicationComponent.class,
          modules = LoginModule.class)
  public interface LoginComponent {
      void inject(LoginActivity activity);
  
      LoginPresenter getLoginPresenter();
  }
  </code></pre>
  
  <p><code>LoginActivity.java</code></p>
  
  <pre><code>public class LoginActivity extends BaseActivity implements LoginView {
  
      private static final String TAG = "LoginActivity";
      @Inject
      SharedPreferences prefs;
  -----
  -----
  -----
   @Override
      public void createDaggerInjections() {
  
          DaggerLoginComponent.builder().applicationComponent(App.getAppInstance(this).getAppComponent())
                  .loginModule(new LoginModule(this))
                  .build();
      }
  </code></pre>
  
  <p>This line <code>@Inject
          SharedPreferences prefs;</code> gives error which is as follows. The same error comes when I try to inject Picasso Instance also.</p>
  
  <pre><code>/home/blackidn/proj/styling android 3/dagger 2/DaggerEx/app/src/main/java/com/mohammad/daggerex/App/App.java:8: error: cannot find symbol
  import com.mohammad.daggerex.dagger.DaggerApplicationComponent;
                                     ^
    symbol:   class DaggerApplicationComponent
    location: package com.mohammad.daggerex.dagger
  /home/blackidn/proj/styling android 3/dagger 2/DaggerEx/app/src/main/java/com/mohammad/daggerex/ui/Login/LoginComponent.java:16: error: android.content.SharedPreferences cannot be provided without an @Provides- or @Produces-annotated method.
      void inject(LoginActivity activity);
           ^
        com.mohammad.daggerex.ui.Login.LoginActivity.prefs
            [injected field of type: android.content.SharedPreferences prefs]
  </code></pre>
  
  <p>Stucked with this and Don't know how to solve this and move forward. What am I missing ? Any help would be great.</p>