test code 작성 중 java 로 코딩 되어 있는 AppModule 에 @Provides 를 kotlin 으로 변환하려고 하는데
예상치로는 아래와 같았지만 계속 되는 컴파일 오류 =_ =;;
@Module
abstract class AppModule {
@Binds
@Singleton
abstract fun provideContext(app: Application): Context
companion object {
@JvmStatic
@Provides
fun provideSharedPreference(context: Context) =
PreferenceManager.getDefaultSharedPreferences(context)
}
}
혹시나해서 찾아보니 (https://stackoverflow.com/questions/48081881/dagger-2-not-injecting-sharedpreference)
companion object 에도 @Module 을 추가해주어야하는 것
@Module
abstract class AppModule {
@Binds
@Singleton
abstract fun provideContext(app: Application): Context
@Module
companion object {
@JvmStatic
@Provides
fun provideSharedPreference(context: Context) =
PreferenceManager.getDefaultSharedPreferences(context)
}
}
예상치로는 아래와 같았지만 계속 되는 컴파일 오류 =_ =;;
@Module
abstract class AppModule {
@Binds
@Singleton
abstract fun provideContext(app: Application): Context
companion object {
@JvmStatic
@Provides
fun provideSharedPreference(context: Context) =
PreferenceManager.getDefaultSharedPreferences(context)
}
}
혹시나해서 찾아보니 (https://stackoverflow.com/questions/48081881/dagger-2-not-injecting-sharedpreference)
companion object 에도 @Module 을 추가해주어야하는 것
@Module
abstract class AppModule {
@Binds
@Singleton
abstract fun provideContext(app: Application): Context
@Module
companion object {
@JvmStatic
@Provides
fun provideSharedPreference(context: Context) =
PreferenceManager.getDefaultSharedPreferences(context)
}
}
'Android' 카테고리의 다른 글
| 어찌 하다보니 usb cam 앱을 수정하는 일을 접했는데 (0) | 2019.01.08 |
|---|---|
| dagger + retrofiit + baseurl 이 다수일때 (0) | 2018.12.11 |
| EditText imeOption= (0) | 2018.12.11 |
| 간만에 어이 없는 삽질.. (0) | 2018.10.30 |
| 간만에 어이 없는 삽질.. (0) | 2018.10.29 |