dagger-2

How do you implement DaggerService

£可爱£侵袭症+ 提交于 2019-12-01 18:29:14
问题 I've looked at the basics as well as the class, but being new to dagger (or even dagger 2) I have no idea how I'm suppose to use this Here is the dagger intent service: https://google.github.io/dagger/api/latest/dagger/android/DaggerIntentService.html I understand the android intent service and the basics for implementing, but I can't seem to find info over the DaggerIntentService (and I also struggle at finding info for DaggerService) My goal is to build it using TDD, but I really just need

How do you implement DaggerService

此生再无相见时 提交于 2019-12-01 17:47:52
I've looked at the basics as well as the class, but being new to dagger (or even dagger 2) I have no idea how I'm suppose to use this Here is the dagger intent service: https://google.github.io/dagger/api/latest/dagger/android/DaggerIntentService.html I understand the android intent service and the basics for implementing, but I can't seem to find info over the DaggerIntentService (and I also struggle at finding info for DaggerService) My goal is to build it using TDD, but I really just need to understand the workflow for implementing a dagger based service Thanks, Kelly bajicdusko This does

Could not find method apt()

喜欢而已 提交于 2019-12-01 17:36:36
I'm trying to work with Dagger2, I am using Android studio 2.2.2 but I have an error with gradle: Error:(34, 0) Could not find method apt() for arguments [com.google.dagger:dagger-compiler:2.6] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. <a href="openFile:C:\Users\edi.bershatsky\Google Drive\Android\eWave\MyCode\MyDagger2\app\build.gradle">Open File</a> please help me to understand what is wrong with my gradle this is my project gradle: // Top-level build file where you can add configuration options common to all sub-projects/modules.

Dagger 2 how to perform constructor injection

放肆的年华 提交于 2019-12-01 16:55:46
I have a class public class DialogUtils { private Context context; @Inject public DialogUtils(Context context) { this.context = context; } } In my activity class i have did but i'm getting null pointer exception on dialogUtils instance. public class LoginActivity extends Activity{ @Inject DialogUtils dialogUtils; } I know how to inject dependency via module and component but not sure how to with construction injection. Any help is much appreciated. If you don't retain the activity-level component and you aren't inheriting from a superscope (application-level component) using component

How do I tell Dagger 2 which implementation to instantiate based on X?

戏子无情 提交于 2019-12-01 16:32:59
Inside a module, if I need to provide a different implementation of an interface based on a variable known at module construction time I can put the logic inside the @Provides method for that interface type. Like so: @Module public class FooModule { private final State state; public FooModule(State state) { this.state = state; } @Provides FooInterface provideFooImplementation() { switch(state) { case STATE_1: return new FooImpl1(); case STATE_2: return new FooImpl2(); ... case STATE_10: return new FooImpl10(); } } } However, these implementations could be created by Dagger. I would rather say

How do I tell Dagger 2 which implementation to instantiate based on X?

◇◆丶佛笑我妖孽 提交于 2019-12-01 15:52:36
问题 Inside a module, if I need to provide a different implementation of an interface based on a variable known at module construction time I can put the logic inside the @Provides method for that interface type. Like so: @Module public class FooModule { private final State state; public FooModule(State state) { this.state = state; } @Provides FooInterface provideFooImplementation() { switch(state) { case STATE_1: return new FooImpl1(); case STATE_2: return new FooImpl2(); ... case STATE_10:

Dagger 2 on Android, missing error messages

廉价感情. 提交于 2019-12-01 15:20:35
I'm using Dagger 2 in my Android project and I'm having trouble debugging it. I know that the compilation fails because of an error in my dagger 2 setup (had it before) but it's almost impossible to track it down because I don't get a proper error message telling me where the problem lies. All I get are messages that show that the annotation processing failed. Along the lines of: Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details. Error:(14, 28) error: cannot find symbol class BR Error:(17, 40) error: package com

Dagger 2 on Android, missing error messages

早过忘川 提交于 2019-12-01 14:11:52
问题 I'm using Dagger 2 in my Android project and I'm having trouble debugging it. I know that the compilation fails because of an error in my dagger 2 setup (had it before) but it's almost impossible to track it down because I don't get a proper error message telling me where the problem lies. All I get are messages that show that the annotation processing failed. Along the lines of: Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error

Trying to get my head around dependency injection on Android with Dagger2

二次信任 提交于 2019-12-01 12:12:50
I have the following code working: SomeClass public class SomeClass { @Inject @Named("special") OkHttpClient mOkHttpClient; public SomeClass(Activity activity) { ((MyApplication) activity.getApplication()).getApplicationComponent().inject(this); } } ApplicationModule @Module public class ApplicationModule { private final Application mApplication; public ApplicationModule(Application application) { mApplication = Preconditions.checkNotNull(application); } @Provides @Singleton Application providesApplication() { return mApplication; } @Provides @Singleton SharedPreferences

Dagger 2.0 - AppEngine - gradle configuration

老子叫甜甜 提交于 2019-12-01 11:28:40
I am trying to move from Dagger 1.2.2 to Dagger 2.0.1 in AppEngine project ( NOT Android one). With Dagger 1.2.2 simple: compile 'com.squareup.dagger:dagger-compiler:1.2.2' compile 'com.squareup.dagger:dagger:1.2.2' did the trick. With Dagger 2.0.1: compile 'com.google.dagger:dagger-compiler:2.0.1' compile 'com.google.dagger:dagger:2.0.1' does not work (source is generated but mixed up with *.class files in build/classes/main/..package../). You can also do it without net.ltgt.apt plugin, (which by the way may conflict with lombok). apply plugin: 'java' apply plugin: 'idea' def generatedMain =