The problem is that you are using
DaggerObjectGraph
which is no longer available in dagger2.
Here is the documentation for dagger 2 .
This is a working version.
at your build.gradle application level add the following under dependency closure
compile "com.google.dagger:dagger:2.9" kapt "com.google.dagger:dagger-compiler:2.9" provided 'javax.annotation:jsr250-api:1.0'
also add this to the same file
kapt { generateStubs = true }
Then create classes of components and modules and enter any actions or fragments that you want.
Here is an example Component Class
@Singleton @Component(modules = arrayOf(AppModule::class, NetModule::class)) interface AppComponent { fun gson() : Gson fun retrofit(): Retrofit fun okHttpClient(): OkHttpClient }
Here is an example of a module class
@Module class AppModule(internal var mApplication: Application) { @Provides @Singleton fun providesApplication(): Application { return mApplication } }
In my application class
class App : Application() { companion object { @JvmStatic lateinit var component: AppComponent } override fun onCreate() { super.onCreate() appComponent = DaggerAppComponent.builder() .appModule(AppModule(this)) .netModule(NetModule(Constants.BASE_URL)) .build() } }
Here's how the dagger components in dagger 2 are initialized. Now you can create subcomponents for various actions or fragments and enter them.
source share