Why does Dagger-2 subcomponent scope not work? -


i'm trying scope subcomponents in dagger 2 following error on build

cannot provided without @inject constructor or @provides- or @produces-annotated method. 

if comment scope annotations, build succeeds. know why? dagger 2 not designed scenario?

parentcomponent.java

import com.cueyoueye.android.inject.annotation.activityscope;  import javax.inject.inject; import javax.inject.singleton;  import dagger.component; import dagger.module; import dagger.provides; import dagger.subcomponent;  @singleton @component(modules = parentcomponent.parentmodule.class) public interface parentcomponent {     subcomponent subcomponent();  //    @activityscope     @subcomponent(modules = subcomponentmodule.class)     interface subcomponent {         void inject(example activity);     }      @module     class subcomponentmodule {         @provides //        @activityscope         b provideb() {             return new b("better");         }     }      class b {         public b(string s) {         }     }      @module     class parentmodule {         @provides         @singleton         ab provideab() {             return new ab("s");         }     }      @singleton     class {         @inject         public a() {         }     }      class ab {         public ab(string s) {         }     } } 

example.java

import javax.inject.inject;  public class example {     @inject     parentcomponent.b b;      public void injectself() {         daggerparentcomponent.builder()                 .build()                 .subcomponent()                 .inject(this);     } } 

this code functional in complete isolation. else causing build error.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -