dagger

Nested/Recursive Injections with Dagger

元气小坏坏 提交于 2019-12-06 03:00:09
问题 When using Dagger, what approaches will allow for free/easy instantiation of @Inject fields on objects that are also instantiated through injection. For example, the code below will inject an object of type Bar into a given Foo object. It will do this in either of the two ways displayed. However, the Sly field of each Bar object is not matching that behavior. Foo public class Foo { @Inject Bar bar; public String getValue() { return "Foo's bar value: " + bar.getValue(); } } Bang public class

Overriding debug module in tests

爷,独闯天下 提交于 2019-12-05 21:51:31
I have a Gradle app with a project structure similar to Jake Wharton's u2020 : /src /androidTest /debug /main /release In my application class I build the Dagger graph and inject it: MyApplication extends Application { ... public void buildObjectGraphAndInject() { Object[] modules = Modules.list(this); mApplicationGraph = ObjectGraph.create(modules); mApplicationGraph.inject(this); } ... } Inside the debug sourceset, I define Modules.list() as: public final class Modules { public static Object[] list(MyApplication app) { return new Object[] { new AppModule(app), new DebugAppModule() }; }

Error: cannot find symbol variable DaggerAppComponent

孤者浪人 提交于 2019-12-05 20:08:05
问题 While trying to integrate latest Dagger 2 version, I am facing problem of Dagger auto generation. Dagger is not auto generating DaggerAppComponent in spite of several Rebuilds and Make Module App process. Application class: public class BaseApplication extends Application { private AppComponent appComponent; @Override public void onCreate() { super.onCreate(); initAppComponent(); } private void initAppComponent() { DaggerAppComponent.builder() .appModule(new AppModule(this)) .build(); }

Kotlin + Dagger inject issue depending on device's Android Version / SDK (?)

只谈情不闲聊 提交于 2019-12-05 18:19:20
Last week, while implementing Dagger in my current Kotlin MVP project, I was testing it on oldy phone with KitKat 4.4.2 (yep, it still supports all major material features and stuff :)) due to primary phone's maintenance. So that week I was having typical issues rather than something unusual and fixed them more or less quickly by investigating provided errors. At long last, code compiled, current project version was built without issues and ran without major bugs on KitKat with UI interacting. But when I took main phone with Nougat 7.1.2 from repair center and launched app on it I stuck with

What is the difference between Dagger and Dagger 2.0?

北城以北 提交于 2019-12-05 18:03:54
What is the difference between Dagger and Dagger 2.0, and why did Google decide to fork the existing project? 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 dynamism No automated migration path from Guice 来源: https://stackoverflow.com/questions/27888580/what-is-the

Android Dagger 2 Dependency not being injected

左心房为你撑大大i 提交于 2019-12-05 12:30:19
i'm trying to use Dagger 2 into my apps but i'm having some problems regarding the entities repository and i haven't figured it out what i'm missing. Here is my Application Component: @Singleton @Component( modules = { AndroidModule.class, RepositoryModule.class } ) public interface ApplicationComponent { void inject(AndroidApplication app); IDependenceyRepository dependencyRepository(); } My modules: @Module public class RepositoryModule { @Provides @Singleton IDependenceyRepository provideDependendencyRepository(Context context) { return new DependencyRepository(context); } } @Module public

How does Transfuse compare with Dagger?

徘徊边缘 提交于 2019-12-05 05:59:38
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. 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. This allows them to avoid the costly runtime reflection-based analysis typically associated with DI containers

Is it possible to integrate Dagger and AspectJ in an Android Studio project?

吃可爱长大的小学妹 提交于 2019-12-05 05:40:23
I'm working in an Android project where I'm using Dagger for dependency injection. I don't know so much about Gradle, but as far as I understand, the Dagger annotations are processed by its compiler once the project is built. There's no problem in configuring it as the user guide says. Well, now I want to integrate AspectJ too, so I'm looking at one of the plugins for Android . However, it seems this plugin does a build post processing job to read the aspects too, which remains in conflict with what Dagger compiler does. That's my current build.gradle file (Built a test project to have a SSCCE

How do I get Dagger and Butterknife working with Gradle?

♀尐吖头ヾ 提交于 2019-12-05 04:48:19
I had my project working great with Butterknife to do view injection. But I then needed to add Dagger in order to inject dependencies. I added the Annotation Processor Tool Gradle plugin with the appropriate Dagger requirement (Only showing the modified parts for brevity); buildScript { repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { ... classpath 'com.jimdo.gradle:gradle-apt-plugin:0.2-SNAPSHOT' } } apply plugin: 'apt' dependencies { apt "com.squareup.dagger:dagger-compiler:${daggerVersion}" ... } At this point now when I build and run

dagger cannot inject type parameter field

送分小仙女□ 提交于 2019-12-05 04:07:30
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(savedInstanceState); ((App) getActivity().getApplication()).inject(this); } } here is my service