Room + Hilt + Zxing | #1
Зависимости в build.gradle (Project): id (“com.google.dagger.hilt.android”) version (“2.46.1”) apply false Зависимости в build.gradle (App) plugins: id(“com.google.dagger.hilt.android”)id(“kotlin-kapt”) Зависимости в build.gradle (App) dependencies: implementation(“com.google.dagger:hilt-android:2.46.1”)kapt(“com.google.dagger:hilt-compiler:2.46.1”)implementation(“androidx.room:room-ktx:2.6.1”)kapt(“androidx.room:room-compiler:2.6.1”)implementation (“com.journeyapps:zxing-android-embedded:4.3.0”) Module: import android.app.Applicationimport androidx.room.Roomimport com.neco_desarrollo.qrcodescanerjetpack.data.MainDbimport dagger.Moduleimport dagger.Providesimport dagger.hilt.InstallInimport dagger.hilt.components.SingletonComponentimport javax.inject.Singleton@Module@InstallIn(SingletonComponent::class)object Module { @Provides @Singleton fun provideMainDb(app: Application) : MainDb{ return Room.databaseBuilder( app, MainDb::class.java, “products.db” ).build() }} MainDb: import androidx.room.Databaseimport androidx.room.RoomDatabase@Database( entities = [Product::class], version = 1)abstract class MainDb : RoomDatabase() { abstract val dao: Dao} Dao: import… Подробнее »Room + Hilt + Zxing | #1