0

Below is my code;

@Module
  public class CUModule {

 private FragmentActivity mActivity;

  public CUModule(FragmentActivity activity) {
this.mActivity = activity;

}


 @Singleton
@Provides
Application provideApplication() {
return mActivity.getApplication();
}


@Singleton
@Provides
DeviceUtils proviceDeviceUtils() {
return new DeviceUtils(mActivity);
}

@Singleton
@Provides
AppDatabase provideDatabase (Application application) {
return Room.databaseBuilder(
        application,
        AppDatabase.class,
        "test_database.db"
).build();
}


}

AppDatabase.java

@Database(entities = [Office::class], version = 1)
abstract class AppDatabase : RoomDatabase() {
abstract fun officeDao(): OfficeDao?
}

Getting below error while run app,

[Dagger/MissingBinding] AppDatabase cannot be provided without an @Provides-annotated method.

Vishal Vaishnav
  • 3,346
  • 3
  • 26
  • 57
  • Is your application has Dependency Component? I guest some object using AppDatabase but not in scope @Singleton – Công Hải May 12 '20 at 07:31
  • Yes it has a dependency component. Can you please explain me what actual means of this error @CôngHải? – Vishal Vaishnav May 12 '20 at 07:39
  • attach Dependency component and parent component code, I will help you – Công Hải May 12 '20 at 07:48
  • Please see [here for some general information](https://stackoverflow.com/q/44912080/1837367). If you're still stuck after reading this, please update your question with all the necessary information or we'll be guessing blindly – David Medenjak May 12 '20 at 09:04

0 Answers0