android - Error with DataDinding and Dagger2 -


i developing project using databinding after add dagger2 , implement module, component , graft have faced error:

error:(8, 74) error: package com.anda.soft.app.databinding not
exist
error:(16, 13) error: cannot find symbol class activitymainbinding
error:execution failed task ':app:compiledebugjavawithjavac'. java.lang.illegalargumentexception: not valid component method: injectpresentationfragmentpresenter()

this module:

@module public class modul {      private context context;       public modul(context context){         this.context = context;     }      @provides     public mainactivity providemainactivity(){         return new mainactivity();     }      @provides     public presentationfragmentpresenter providepresentationfragment(){         return new presentationfragmentpresenterimp(providemainactivity());     }  } 

my compoment:

@component (modules = modul.class )  public interface compoment {  void injectpresentationfragmentpresenter(); } 

and graph

public class app extends application {      private compoment mcompoment;      @override     public void oncreate() {         super.oncreate();          setupgraph();     }      private void setupgraph() {         mcompoment = daggercompoment.builder()                 .modul(new modul(this))                 .build();     }       public compoment getcompoment(){         return mcompoment;     } } 

finally mainactivity

    private activitymainbinding mactivitymainbinding ;     @inject presentationfragmentpresenter mview;     private toolbar mtoolbar;       @override     protected void bindview(int layoutresource) {         mview = new presentationfragmentpresenterimp(this);         mactivitymainbinding = databindingutil.setcontentview(this,layoutresource);     }      @override     public int getlayoutresource() {         return r.layout.activity_main;     } 

what doing wrong ? know if there incompatibilities between dagger , databinding?

a component has 2 ways of providing dependendencies:

provision methods return injected or provided type.

here's example of provision method. note method returns dependency, in case okhttpclient.

okhttpclient httpclient(); 

members-injection methods inject dependencies particular type.

here's example of members-injection method. note takes single argument, type injected dependencies (in case mainactivity:

void inject(mainactivity activity); 

you can read more components @ dagger 2 @component javadocs.

your problem void injectpresentationfragmentpresenter(); neither of these. doesn't return anything, isn't provision method. takes no argument, can't members-injection method. based on naming of method , rest of post, i'm guessing want define method so:

void injectpresentationfragmentpresenter(presentationfragmentpresenter presenter); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -