title: Dagger 2 lifecycle of a component, module and scope
body: <p>I've read a lot of posts and tutorials about dagger 2:</p>
  
  <p><a href="http://frogermcs.github.io/dependency-injection-with-dagger-2-custom-scopes/" rel="noreferrer">http://frogermcs.github.io/dependency-injection-with-dagger-2-custom-scopes/</a></p>
  
  <p><a href="https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2" rel="noreferrer">https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2</a></p>
  
  <p><a href="http://fernandocejas.com/2015/04/11/tasting-dagger-2-on-android/" rel="noreferrer">http://fernandocejas.com/2015/04/11/tasting-dagger-2-on-android/</a></p>
  
  <p><a href="https://github.com/konmik/konmik.github.io/wiki/Snorkeling-with-Dagger-2" rel="noreferrer">https://github.com/konmik/konmik.github.io/wiki/Snorkeling-with-Dagger-2</a></p>
  
  <p><a href="https://stackoverflow.com/questions/28411352/what-determines-the-lifecycle-of-a-component-object-graph-in-dagger-2">What determines the lifecycle of a component (object graph) in Dagger 2?</a></p>
  
  <p>etc.</p>
  
  <p>But I am still confused about the lifecycle of a component, and how it relates to module and scope. I want to make sure I don't create multiple instances of an object when I only want a Singleton. Hope someone can shed some light on these:</p>
  
  <p>What's the lifecycle of a component that's built in the application class?</p>
  
  <p>What's the lifecycle of a component that's built in the Activity or Fragment class? </p>
  
  <p>If I want a singleton instance from a component, do I must annotate the component with @Singleton or a custom made scope and build that component in the application class?</p>
  
  <p>If I build a component in the application class, does that mean all the object instances available through this component will be a singleton instance throughout the app until the app is killed or restarted?</p>
  
  <p>I have a component with a custom scope let's say @ActivityScope, and I build that component in an Activity, will the object instances injected through this component be destroyed automatically after this activity's onDestroy() is called?</p>
  
  <p>Again I have a component with a custom scope let's say @ActivityScope, and I build this component in ActivityA and ActivityB, will ActivityA and ActivityB share the same object instances from this component or they will have their own instances of the same object?</p>