dagger-2

Dagger2 - Project Rebuild Error - Field Injection - Android

我的梦境 提交于 2019-12-20 07:36:44
问题 I have been trying to implement Dagger2. Problem: When I use constructor injection, it works fine but when I use field injection, it throws an Error like below: Error:(6, 48) error: cannot find symbol class DaggerApplicationComponent /home/moderator/Downloads/Maulik/Sample Codes/Made/Dagger2Demo/app/src/main/java/com/dagger2demo/dagger2demo/di/component/ApplicationComponent.java Error:(18, 10) error: com.dagger2demo.dagger2demo.mvp.HomePresenter cannot be provided without an @Inject

Dagger generating multiple instances of retrofit interceptor

梦想的初衷 提交于 2019-12-20 04:43:05
问题 I am new to Dagger and Retrofit. I am having issue where multiple instances of retrofit custom interceptor are being generated despite declared singleton in dagger module. I only require one instance. Dagger Module @Module public class ApiModule { private Config config; public ApiModule(Config config) { this.config = config; } @Provides @Singleton public OkHttpClient.Builder provideOkHttpClient() { return new OkHttpClient.Builder(); } @Provides @Singleton public

Could not find method apt()

核能气质少年 提交于 2019-12-19 17:45:33
问题 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: //

Espresso, Dagger2 set ViemodelProvider.Factory on BaseActivity

ぃ、小莉子 提交于 2019-12-19 05:21:03
问题 I have an abstract AccountRequiredActivity that looks like this (and works fine): public abstract class AccountRequiredActivity extends LifecycleActivity { @Inject ViewModelProvider.Factory viewModelFactory; private AccountViewModel accountViewModel; public abstract void doOnCreate(Bundle savedInstanceState); public abstract void doOnResume(); @Override protected final void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_loading_app);

Dagger 2 - injecting non Android classes

狂风中的少年 提交于 2019-12-19 04:10:34
问题 I'm implimenting Dagger 2 in my Android app. I have it setup in the following way: AppComponent.java @Singleton @Component(modules = { AndroidInjectionModule.class, AndroidSupportInjectionModule.class, ActivityBuilder.class, AppModule.class, DataBaseDaoModule.class }) public interface AppComponent { @Component.Builder interface Builder { @BindsInstance Builder application(Application aApplication); AppComponent build(); } Application application(); void inject(MyApplication aApplication); }

Understanding scopes in Dagger 2

霸气de小男生 提交于 2019-12-19 02:47:16
问题 I have an scope-related error in Dagger 2 and I'm trying to understand how I can solve it. I have a CompaniesActivity that shows companies. When the user selects an item, selected company's employees are shown in EmployeesActivity . When the user selects an employee, her detail is shown in EmployeeDetailActivity . class Company { List<Employee> employees; } Class CompaniesViewModel contains the companies and the selected one (or null ): class CompaniesViewModel { List<Company> companies;

UninitializedPropertyAccessException: lateinit property pref has not been initialized

橙三吉。 提交于 2019-12-18 14:56:35
问题 I know this question has been answered [Here] (lateinit property has not been initialized). But that was due to butter knife library problem But my case is different. completely different. In my case when I use dagger injected properties in my base activity it shows me error Caused by: kotlin.UninitializedPropertyAccessException: lateinit property pref has not been initialized But same property when I use in my sub activity (Login activity) it works fine. eg. pref.setLanguage("abc") -> it

cannot find symbol class DaggerAppComponent or cannot find symbol class DaggerActivityComponent

一个人想着一个人 提交于 2019-12-18 12:58:11
问题 I get this error after adding inject on my class then it gives me a compilation error. If I remove @Inject static ApiService mApiService; it's working fine And I'm using 2 Application class those are extended MultidexApplication because I have merge 2 application first is using dagger2 and second application is butterknife and both directory structure are differnet and both application interdependently working fine but after merge the code application not compile and give DaggerAppComponent

Dagger2 generated class is all of a sudden missing from Android Studio

本秂侑毒 提交于 2019-12-18 12:23:43
问题 I have been using Dagger2 in Android Studio for months now but today all of sudden it stopped working and is giving me the following error error: cannot find symbol return Dagger_Injector.builder() ^ symbol: variable Dagger_Injector location: class Initializer Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error Here is

Dagger 2 examples [closed]

余生长醉 提交于 2019-12-18 10:13:11
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Dagger 2 is around the corner but the available examples wouldn't even compile right off the box, and the documentation is a copy-paste-replace from Dagger 1. Does anyone have an example of a proper application working on Google's Dagger 2? 回答1: I've just published sample app based on Gradle which integrates