dagger

Dagger 2 - injecting multiple objects of same type using @Named not working

ε祈祈猫儿з 提交于 2019-12-07 19:37:37
问题 My module: @Module public class TcpManagerModule { private ITcpConnection eventsTcpConnection; private ITcpConnection commandsTcpConnection; public TcpManagerModule(Context context) { eventsTcpConnection = new EventsTcpConnection(context); commandsTcpConnection = new CommandsTcpConnection(context); } @Provides @Named("events") public ITcpConnection provideEventsTcpConnection() { return eventsTcpConnection; } @Provides @Named("commands") public ITcpConnection provideCommandsTcpConnection() {

What is the difference between Dagger and Dagger 2.0?

跟風遠走 提交于 2019-12-07 11:10:33
问题 What is the difference between Dagger and Dagger 2.0, and why did Google decide to fork the existing project? 回答1: Some quotes from the Dagger 2 presentation Issues of Dagger 1: Ugly generated code Runtime graph composition Inefficient graph creation Partial traceability Map-like API Dagger 2 solutions: Compile-time validation of the entire graph Easy debugging; entirely concrete call stack for provision and creation Fully traceable POJO API Performance Dagger 2 issues: Less flexible No

How does Transfuse compare with Dagger?

耗尽温柔 提交于 2019-12-07 02:36:49
问题 I'm trying to decide whether to use Transfuse or Dagger for Android dependency injection. I've never used Transfuse, and have basic knowledge of Dagger. Thanks much. 回答1: To start, I am the primary author of Transfuse thus this answer may be a bit slanted in that direction. Both Transfuse and Dagger handle Dependency Injection / Inversion of Control for Android in similar ways. Both use Annotation Processing at Compile time via JSR269 to generate code the supports the DI/IOC functionality.

dagger cannot inject type parameter field

折月煮酒 提交于 2019-12-07 00:36:20
问题 I'm working on an android application and I'm trying to inject a field which is type parameterized in an abstract class : BaseListFragment public abstract class BaseListFragment<E, A extends ArrayAdapter<E>, S> extends BaseFragment { @Inject protected S service; } But I get this following error at compile : error: cannot find symbol class S Here is my code for BaseFragment : public class BaseFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

AndroidAnnotations and Dagger

三世轮回 提交于 2019-12-06 22:05:39
问题 I'm trying to use Dagger to inject into an android Annotated Activity. java.lang.IllegalArgumentException: No inject registered for members/com.app.server.AddServerActivity_. You must explicitly add it to the 'injects' option in one of your modules. If I try and Add the com.app.server.AddServerActivity_ to the module I get a diffrent error Error: java.lang.ClassCastException: com.sun.tools.javac.code.Attribute$Error cannot be cast to com.sun.tools.javac.code.Attribute$Class java.lang

Android Dagger Dependency Injection fails on private Fields

一个人想着一个人 提交于 2019-12-06 17:18:04
问题 I'm new to dagger (though I have experience with DI from working on Java EE WebApps using Weld). What I'm trying to do is to inject a dependency into a class. The field is private. Dagger then throws an exception stating it can't inject into a private field. What's the reason for that? After all it is possible to write to private fields using reflections, even on android.. If I set the visibility of the field to something other than private the injection seems to work. 回答1: Making a private

Dagger - nested injections, is it necessary to call inject()?

我们两清 提交于 2019-12-06 08:31:36
问题 I'm new to Dagger and at the begininig I face some issues. I have simple structure so far in my project. My injection module: @Module( injects = {GameBoardFragment.class, GameManager.class}, complete = false, library = true ) public class GameObjectsProviderModule { private final Application mApplication; public GameObjectsProviderModule(Application application){ this.mApplication = application; } @Provides @Singleton public GameManager provideGameManager(){ return new GameManager(); }

Google Auto Factory / Dagger Integration: Dependencies on injected code

…衆ロ難τιáo~ 提交于 2019-12-06 08:22:16
问题 It seems that Dagger doesn't explain at all how to deal with providing / managing auto generated code, such as what Google Auto Factory creates. Also the people at Google Auto don't really explain how to integrate back with Dagger so it's causing a pain for people like myself without very senior knowledge of how both libraries work. The problem I'm seeing is that when you are not providing fully qualified names to factories generated by Google Auto Factory, Dagger will not pick them up at all

Google Auto Factory: not annotated with @Provided?

别来无恙 提交于 2019-12-06 04:51:08
问题 So I'm trying out google auto factory but I get a strange error. Factory class: @AutoFactory( className = "MembersAdapterFactoryImpl" ) public class MembersAdapter extends ArrayAdapter<Member> { /** * Get an instance of the helper */ private MembersAdapterHelper mMembersAdapterHelper; public MembersAdapter(@Provided MembersAdapterHelper membersAdapterHelper, Context context, int resource, List<Member> members){ super(context, resource, members); mMembersAdapterHelper = membersAdapterHelper; }

Add Retrofit Requestinterceptor with Dagger at runtime

痴心易碎 提交于 2019-12-06 04:17:54
I'm using dagger and retrofit. I inject my Retrofit services with Dagger. Now i wanna do a authorization request to get an accessToken. Afterwards i want to enhance my api module with an Request interceptor to use this access token for future requests. My idea is to use the ObjectGraph.plus() method after i received the access token, but i'm not sure if this is the best way to do it. Can someone point me to the right direction or maybe is there an example project on github ? The key is to always add the RequestInterceptor and then change whether or not it adds the header. class ApiHeaders