Stevekitkat
04/17/2024, 3:28 PMe: [ksp] --> Missing Definition type 'android.content.Context' for 'me.androidbox.data.local.imp.UserTokenLocalDataSourceImp'. Fix your configuration to define type 'Context'.
e: Error occurred in KSP, check log for detail
@Single
class UserTokenLocalDataSourceImp(context: Context) : UserTokenLocalDataSource {
companion object {
private const val TOKEN = "token"
private const val FILE_NAME = "secret_shared_prefs"
}
private val masterKeys = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
private val encryptedSharedPreferences =
EncryptedSharedPreferences.create(
FILE_NAME,
masterKeys,
context,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
override suspend fun saveUserToken(token: String) {
encryptedSharedPreferences.edit {
this.putString(TOKEN, token)
this.apply()
}
}
override suspend fun fetchUserToken(): String? {
return encryptedSharedPreferences.getString(TOKEN, null)
}
}
In my module I have the following:
@Module
@ComponentScan
class UserTokenLocalDataSourceModule {
@Single
fun provideUserTokenLocalDataSourceImp(): UserTokenLocalDataSource {
return UserTokenLocalDataSourceImp(androidContext())
}
}
I thought I could use the androidContext()
the same way we use the koin DSL, but I get the following androidContext() unresolved reference
In my application class I have the following:
startKoin {
androidLogger()
androidContext(this@BusbyTravelMateApplication)
modules(
UserTokenLocalDataSourceModule().module,
)
}
kspVersion = "1.9.23-1.0.20"
koinVersion = "3.5.3"
kspKoinVersion = "1.3.0"