@Singleton @Provides fun provideContext(@ApplicationContext context: Context): Context { return context }
implementation "com.google.dagger:hilt-android:2.28-alpha" kapt "com.google.dagger:hilt-compiler:2.28-alpha"
@HiltAndroidApp class MyApplication : Application()
plugins { id 'com.android.library' id 'kotlin-android' // Add this line id 'dagger.hilt.android.plugin' }
dependencies { implementation "com.google.dagger:hilt-android:2.28-alpha" kapt "com.google.dagger:hilt-compiler:2.28-alpha"
// Add this line
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
kapt "androidx.hilt:hilt-compiler:1.0.0-alpha03"
}
这些步骤应该帮助您解决Android Multi Module和Hilt的问题。
下一篇:Android目录