Closed sarn0ld closed 9 months ago
I have the same problem when using annotations and have the KOIN_CONFIG_CHECK enabled.
I create an PR https://github.com/InsertKoinIO/koin-annotations/pull/101
e: [ksp] --> Missing Definition type 'android.app.Application' for '***'. Fix your configuration to define type 'Application'.
e: [ksp] --> Missing Definition type 'kotlinx.coroutines.CoroutineDispatcher' for '***'. Fix your configuration to define type 'CoroutineDispatcher'.
e: [ksp] --> Missing Definition type 'android.content.Context' for '***'. Fix your configuration to define type 'Context'.
e: [ksp] --> Missing Definition type 'kotlin.String' for '***'. Fix your configuration to define type 'String'.
e: [ksp] --> Missing Definition type 'android.content.SharedPreferences' for '***'. Fix your configuration to define type 'SharedPreferences'.
e: [ksp] --> Missing Definition type 'androidx.work.WorkManager' for '***'. Fix your configuration to define type 'WorkManager'.
e: [ksp] --> Missing Definition type 'androidx.work.OneTimeWorkRequest' for '***'. Fix your configuration to define type 'OneTimeWorkRequest'.
I have a few more issues with this ticket.
cc: @ghasemdev
e: [ksp] --> Missing Definition type 'android.app.Application' for '***'. Fix your configuration to define type 'Application'. e: [ksp] --> Missing Definition type 'kotlinx.coroutines.CoroutineDispatcher' for '***'. Fix your configuration to define type 'CoroutineDispatcher'. e: [ksp] --> Missing Definition type 'android.content.Context' for '***'. Fix your configuration to define type 'Context'. e: [ksp] --> Missing Definition type 'kotlin.String' for '***'. Fix your configuration to define type 'String'. e: [ksp] --> Missing Definition type 'android.content.SharedPreferences' for '***'. Fix your configuration to define type 'SharedPreferences'. e: [ksp] --> Missing Definition type 'androidx.work.WorkManager' for '***'. Fix your configuration to define type 'WorkManager'. e: [ksp] --> Missing Definition type 'androidx.work.OneTimeWorkRequest' for '***'. Fix your configuration to define type 'OneTimeWorkRequest'.
I have a few more issues with this ticket.
cc: @ghasemdev
I am also experiencing this issue in the sample project I’m working on when using the regular provide module { }
.
e: [ksp] --> Missing Definition type 'com.parsuomash.sdk.di.Token' for 'com.parsuomash.sdk.domain.usecase.Koo'. Fix your configuration to define type 'Token'.
e: [ksp] --> Missing Definition type 'kotlinx.coroutines.CoroutineDispatcher' for 'com.parsuomash.sdk.domain.usecase.UseCase'. Fix your configuration to define type 'CoroutineDispatcher'.
e: [ksp] --> Missing Definition type 'android.content.SharedPreferences' for 'com.parsuomash.sdk.domain.usecase.UseCase'. Fix your configuration to define type 'SharedPreferences'.
e: [ksp] --> Missing Definition type 'android.app.Application' for 'com.parsuomash.sdk.di.Session'. Fix your configuration to define type 'Application'.
e: [ksp] --> Missing Definition type 'android.content.Context' for 'com.parsuomash.sdk.di.Session'. Fix your configuration to define type 'Context'.
e: [ksp] --> Missing Definition type 'androidx.lifecycle.SavedStateHandle' for 'com.parsuomash.sdk.SDKViewModel'. Fix your configuration to define type 'SavedStateHandle'.
e: [ksp] --> Missing Definition type 'com.parsuomash.sdk.SDK' for 'com.parsuomash.sdk.SDKViewModel'. Fix your configuration to define type 'SDK'.
internal val tokenModule = module {
factory {
Token("dkjgfiuebvldvyl")
}
}
@JvmInline
value class Token(val value: String)
internal val coroutinesModule = module {
single {
Dispatchers.IO
} withOptions {
named("IO")
createdAtStart()
}
single {
Dispatchers.Default
} withOptions {
named("Default")
createdAtStart()
}
single {
Dispatchers.Main
} withOptions {
named("Main")
createdAtStart()
}
}
internal val sharedPrefModule = module {
single {
provideSharedPref(androidContext())
} withOptions {
named("SDKSharedPref")
createdAtStart()
}
}
private fun provideSharedPref(
context: Context,
name: String = context.packageName
): SharedPreferences = context.getSharedPreferences(name, MODE_PRIVATE)
private val sdkModule = module {
single {
provideSDK(androidContext()) {
token = sharedPreferences.getString("token", "null") ?: "null"
}
} withOptions {
createdAtStart()
}
}
Can you send the codes for providing the WorkManager
& OneTimeWorkRequest
and where you used it?
@I-sty
e: [ksp] --> Missing Definition type 'android.app.Application' for '***'. Fix your configuration to define type 'Application'. e: [ksp] --> Missing Definition type 'kotlinx.coroutines.CoroutineDispatcher' for '***'. Fix your configuration to define type 'CoroutineDispatcher'. e: [ksp] --> Missing Definition type 'android.content.Context' for '***'. Fix your configuration to define type 'Context'. e: [ksp] --> Missing Definition type 'kotlin.String' for '***'. Fix your configuration to define type 'String'. e: [ksp] --> Missing Definition type 'android.content.SharedPreferences' for '***'. Fix your configuration to define type 'SharedPreferences'. e: [ksp] --> Missing Definition type 'androidx.work.WorkManager' for '***'. Fix your configuration to define type 'WorkManager'. e: [ksp] --> Missing Definition type 'androidx.work.OneTimeWorkRequest' for '***'. Fix your configuration to define type 'OneTimeWorkRequest'.
I have a few more issues with this ticket. cc: @ghasemdev
I am also experiencing this issue in the sample project I’m working on when using the regular provide
module { }
.e: [ksp] --> Missing Definition type 'com.parsuomash.sdk.di.Token' for 'com.parsuomash.sdk.domain.usecase.Koo'. Fix your configuration to define type 'Token'. e: [ksp] --> Missing Definition type 'kotlinx.coroutines.CoroutineDispatcher' for 'com.parsuomash.sdk.domain.usecase.UseCase'. Fix your configuration to define type 'CoroutineDispatcher'. e: [ksp] --> Missing Definition type 'android.content.SharedPreferences' for 'com.parsuomash.sdk.domain.usecase.UseCase'. Fix your configuration to define type 'SharedPreferences'. e: [ksp] --> Missing Definition type 'android.app.Application' for 'com.parsuomash.sdk.di.Session'. Fix your configuration to define type 'Application'. e: [ksp] --> Missing Definition type 'android.content.Context' for 'com.parsuomash.sdk.di.Session'. Fix your configuration to define type 'Context'. e: [ksp] --> Missing Definition type 'androidx.lifecycle.SavedStateHandle' for 'com.parsuomash.sdk.SDKViewModel'. Fix your configuration to define type 'SavedStateHandle'. e: [ksp] --> Missing Definition type 'com.parsuomash.sdk.SDK' for 'com.parsuomash.sdk.SDKViewModel'. Fix your configuration to define type 'SDK'.
internal val tokenModule = module { factory { Token("dkjgfiuebvldvyl") } } @JvmInline value class Token(val value: String) internal val coroutinesModule = module { single { Dispatchers.IO } withOptions { named("IO") createdAtStart() } single { Dispatchers.Default } withOptions { named("Default") createdAtStart() } single { Dispatchers.Main } withOptions { named("Main") createdAtStart() } } internal val sharedPrefModule = module { single { provideSharedPref(androidContext()) } withOptions { named("SDKSharedPref") createdAtStart() } } private fun provideSharedPref( context: Context, name: String = context.packageName ): SharedPreferences = context.getSharedPreferences(name, MODE_PRIVATE) private val sdkModule = module { single { provideSDK(androidContext()) { token = sharedPreferences.getString("token", "null") ?: "null" } } withOptions { createdAtStart() } }
But in this way there is no longer a Missing Definition error.
@Module
internal class CoroutinesModule {
@Singleton(createdAtStart = true)
@Named("IO")
fun provideIODispatcher() = Dispatchers.IO
@Singleton(createdAtStart = true)
@Named("Default")
fun provideDefaultDispatcher() = Dispatchers.Default
@Singleton(createdAtStart = true)
@Named("Main")
fun provideMainDispatcher() = Dispatchers.Main
}
Perhaps a tag is needed to exclude the regular modules of koin.
@IgnoreModule
internal val sharedPrefModule = module {
single {
provideSharedPref(androidContext())
} withOptions {
named("SDKSharedPref")
createdAtStart()
}
}
@arnaudgiuliani
Yeah, android elements must be ignored somewhere. It's a "known" issue of current implementation 👍
@ghasemdev interesting to also add somewhere @Ignore to avoid checking it if needed. Let's challenge it 🤔
Let's see #101
Describe the bug I tried the new ksp flag "KOIN_CONFIG_CHECK" in an Android project.
Now I get compilation errors for Android specific classes:
To Reproduce Steps to reproduce the behavior:
Context
andSavedStateHandle
in it's dependency treeExpected behavior No compile errors
Koin module and version: