dagger-2

Dagger 2 “Dagger” prefix component not able to compile? auto generated class

て烟熏妆下的殇ゞ 提交于 2019-12-05 16:50:54
问题 Im trying to use Dagger 2 on android. I previously had it working and i had an appModule injecting dependencies into specific classes in the app. My Issue is that iam getting the error Error:(14, 55) error: cannot find symbol class DaggerAppComponent which attempting to import. this is an autogenerated class below are my Dagger specific dependencies in my build.gradle file compile 'com.google.dagger:dagger-compiler:2.0.2' compile 'com.google.dagger:dagger:2.0.2' provided 'javax.annotation

Dagger2 androidTest error duplicate entry: javax/annotation/Generated.class

耗尽温柔 提交于 2019-12-05 16:21:54
I'm using Dagger2 for DI. My project has 2 modules, a :common module which is a library and an :app module which is the actual application. In the library module I have AndroidApp which extends MultiDexApplication and is inherited in :app module. I have followed Google's dagger2 example to add DI with Dagger2. Each time I run the app I get the following message as an error: Android/common/src/main/java/com/common/AndroidApp.java:10: The import com.common.di.DaggerAndroidAppComponent cannot be resolved. but the weird part is that Android Studio says BUILD SUCESSFULL and the app runs without

Dagger 2: How to inject Map<Class<? extends Foo>, Provider<? extends Foo>>

孤者浪人 提交于 2019-12-05 14:14:13
In Dagger 2, is it possible to inject a Map<Class<? extends Foo>, Provider<? extends Foo>> ? Suppose, I have a couple of classes that extends Foo class Bar extends Foo { @Inject Bar() {} } class Baz extends Foo { @Inject Baz() {} } and now I want to create a FooFactory by declaring class FooFactory { @Inject FooFactory(Map<Class<? extends Foo>, Provider<? extends Foo>> providers) {} } Can I do this in Dagger 2 with minimal configuration? I've read about Multibinding but I couldn't get it to work. Answering my own question in accordance to the guidelines . First, you have to get rid of 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

Cannot find symbol class “Generated” for Dagger 2

拟墨画扇 提交于 2019-12-05 09:19:09
问题 I just started doing dependency injection using Dagger 2 . When I spun up my modules , components and tried to build my application, gradle threw the error Error:(4, 24) error: cannot find symbol class Generated I dug into it and found that the error is in one of the classes Dagger generates to do DI . The particular class that's missing was javax.annotation.Generated and the line throwing the error is the line that anntotates a Dagger generated class as @Generated("dagger.internal.codegen

Android Dagger 2 POJO field Inject null

笑着哭i 提交于 2019-12-05 07:29:59
Just started using Dagger 2 today and I'm a bit confused on how exactly I need to set everything up. I'm trying to inject a POJO, but it's always null. First, some code: App.java private AppComponent appComponent; @Override public void onCreate() { super.onCreate(); appComponent = DaggerAppComponent .builder() .appModule(new AppModule(this)) .build(); } public AppComponent component() { return appComponent; } AppModule.java @Module public class AppModule { private Application app; public AppModule(Application app) { this.app = app; } @Provides @Singleton public Application application() {

Dagger 2 components not generated when using Jack

谁说我不能喝 提交于 2019-12-05 07:06:58
When I enable the Jack compiler in Android Studio 2.2 the Dagger 2 component is not generated. Can Dagger 2 be used with Jack? If so, how would I go about configuring my application? From my application's build.gradle : jackOptions { enabled true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } gMale I sunk like 2 days into figuring this out. So I'm circling back to posting the findings here in case it saves someone time: This is caused by a bug in Jack that prevents classpaths from working properly . It has to do with Jack running

Can not resolve symbol DaggerApplicationComponent

你离开我真会死。 提交于 2019-12-05 06:50:15
I use Dagger2 with java and I got "Can not resolve symbol DaggerApplicationComponent error in my application." Seems there is something wrong with dependencies. Any help would be really appreciated. My complete code is here- https://github.com/rohitku860/AndroidMvpDagger2 Here is my app graddle with dependencies: apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { applicationId "com.example.android.androidmvpdagger2" minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

AndroidInjector<android.app.Activity> cannot be provided without an @Provides- or @Produces-annotated method

感情迁移 提交于 2019-12-05 06:19:41
I'm getting the error while trying to get the new Android dagger classes from Dagger v2.11 working in our project. I'm not exactly sure what the problem is, as I've taken into account the Android documentation over at https://google.github.io/dagger//android.html and still cannot get over this issue. Any ideas on what's wrong with this setup? MyApplication: public class MyApplication extends Application implements HasActivityInjector { @Inject AndroidInjector<Activity> androidInjector; @Override public void onCreate() { super.onCreate(); AppInjector.init(this); } @Override public

Dagger2 cannot access nullable. javax.annotation.Nullable not found

烈酒焚心 提交于 2019-12-05 05:08:48
I have a module to provide a Retrofit interface. @Module class NetModule(val base: String) { @Provides @Singleton fun provideOkHttpClient(): OkHttpClient { return OkHttpClient.Builder() .addInterceptor(object: Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val request = chain.request() info("Request for ${request.url()}") return chain.proceed(request) } }).build() } @Provides @Singleton fun provideGson(): Gson { return GsonBuilder() .enableComplexMapKeySerialization() .serializeNulls() .setPrettyPrinting() .setLenient() .create() } @Provides @Singleton fun