最佳答案
升级后的匕首柄(版本: 2.31-alpha
) ApplicationComponent.class
找不到。
对于像 RoomDatabase 这样的 Component
,有什么替代方案吗?
@Module
@InstallIn(ApplicationComponent::class)
class RoomModule() {
private val DATABASE_NAME = "salat_time"
@Singleton
@Provides
fun provideRoomDatabase(@ApplicationContext appContext: Context) = Room.databaseBuilder(
appContext,
AppDatabase::class.java,
DATABASE_NAME
).createFromAsset("db/$DATABASE_NAME.sqlite").build()
@Singleton
@Provides
fun provideLocalSalatRepository(database: AppDatabase) = LocalSalatRepository(database)
@Singleton
@Provides
fun provideDistrictRepository(database: AppDatabase) = DistrictRepository(database)
}