Intro
I migrated to Koin 3.2.0 (Koin annotation 1.0.0-beta-2) and started rewriting the code with annotations. The project uses several product flavors. When you run a Gradle, then it displays Overload resolution ambiguity and Conflicting declarations errors for each Build variant, which prevents from getting a working build.
I use ./gradlew build --warning-mode all
command for getting error details (see logs attachment).
This is interfering with the normal build process in App Center. How can this be fixed? Thanks
Error
> Task :app:compileProdReleaseKotlin
Execution optimizations have been disabled for task ':app:compileProdReleaseKotlin' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/Users/admin/projects/test-koin/app/build/generated/ksp/dev6Debug/kotlin'. Reason: Task ':app:compileProdReleaseKotlin' uses this output of task ':app:kspDev6DebugKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/Users/admin/projects/test-koin/app/build/generated/ksp/dev6Release/kotlin'. Reason: Task ':app:compileProdReleaseKotlin' uses this output of task ':app:kspDev6ReleaseKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/Users/admin/projects/test-koin/app/build/generated/ksp/prodDebug/kotlin'. Reason: Task ':app:compileProdReleaseKotlin' uses this output of task ':app:kspProdDebugKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: '/Users/admin/projects/test-koin/app/build/generated/ksp/dev6Debug/kotlin'. Reason: Task ':app:compileProdReleaseKotlin' uses this output of task ':app:kspDev6DebugKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.4.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/Users/admin/projects/test-koin/app/build/generated/ksp/dev6Release/kotlin'. Reason: Task ':app:compileProdReleaseKotlin' uses this output of task ':app:kspDev6ReleaseKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.4.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/Users/admin/projects/test-koin/app/build/generated/ksp/prodDebug/kotlin'. Reason: Task ':app:compileProdReleaseKotlin' uses this output of task ':app:kspProdDebugKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.4.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
e: /Users/admin/projects/test-koin/app/build/generated/ksp/dev6Debug/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (4, 5): Conflicting declarations: public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/dev6Debug/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 42): Conflicting declarations: public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/dev6Debug/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 87): Overload resolution ambiguity:
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
e: /Users/admin/projects/test-koin/app/build/generated/ksp/dev6Release/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (4, 5): Conflicting declarations: public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/dev6Release/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 42): Conflicting declarations: public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/dev6Release/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 87): Overload resolution ambiguity:
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
e: /Users/admin/projects/test-koin/app/build/generated/ksp/prodDebug/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (4, 5): Conflicting declarations: public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/prodDebug/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 42): Conflicting declarations: public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/prodDebug/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 87): Overload resolution ambiguity:
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
e: /Users/admin/projects/test-koin/app/build/generated/ksp/prodRelease/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (4, 5): Conflicting declarations: public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module, public val AppModuleModule: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/prodRelease/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 42): Conflicting declarations: public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module, public val AppModule.module: Module
e: /Users/admin/projects/test-koin/app/build/generated/ksp/prodRelease/kotlin/org/koin/ksp/generated/AppModuleGen.kt: (61, 87): Overload resolution ambiguity:
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModuleModule: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
e: /Users/admin/projects/test-koin/app/src/main/java/com/mysite/core/App.kt: (56, 33): Overload resolution ambiguity:
public val AppModule.module: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModule.module: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModule.module: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
public val AppModule.module: Module defined in org.koin.ksp.generated in file AppModuleGen.kt
> Task :app:compileProdReleaseKotlin FAILED
build.gradle (root level)
buildscript {
ext {
kotlin_version = '1.6.21'
nav_version = '2.5.0-beta01'
input_mask_version = '6.1.0'
}
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app level)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'kotlin-android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs'
id 'kotlin-parcelize'
id 'com.google.devtools.ksp' version "1.6.21-1.0.5"
}
android {
compileSdkVersion 31
buildToolsVersion '31.0.0'
defaultConfig {
applicationId "com.mysite"
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName "2.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
manifestPlaceholders = [appAuthRedirectScheme: 'com.mysite']
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "environment"
productFlavors {
dev6 {
dimension "environment"
versionNameSuffix "-dev6"
}
prod {
dimension "environment"
versionNameSuffix "-prod"
}
}
buildFeatures {
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
// For KSP
applicationVariants.all { variant ->
variant.sourceSets.java.each {
it.srcDirs += "build/generated/ksp/${variant.name}/kotlin"
}
}
}
dependencies {
// Kotlin
implementation 'androidx.core:core-ktx:1.7.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// Core
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.activity:activity-ktx:1.4.0'
implementation 'androidx.fragment:fragment-ktx:1.4.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
// Lifecycle
def lifecycle_version = '2.4.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
// Coroutines
def coroutines_version = '1.6.1'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
// Ktor
def ktor_version = '1.6.6'
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-cio:$ktor_version"
implementation "io.ktor:ktor-client-gson:$ktor_version"
implementation "io.ktor:ktor-client-logging-jvm:$ktor_version"
// Koin
def koin_version = '3.2.0'
def koin_annotations_version = '1.0.0-beta-2'
implementation "io.insert-koin:koin-android:$koin_version"
implementation "io.insert-koin:koin-androidx-navigation:$koin_version"
implementation "io.insert-koin:koin-annotations:$koin_annotations_version"
ksp "io.insert-koin:koin-ksp-compiler:$koin_annotations_version"
// Room
def room_version = '2.4.0'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
// Timber
implementation 'com.jakewharton.timber:timber:5.0.1'
// Testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
App.kt
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import org.koin.core.logger.Level
import org.koin.ksp.generated.module
class App : Application() {
override fun onCreate() {
super.onCreate()
initKoin()
}
private fun initKoin() {
startKoin {
androidContext(this@App)
modules(AppModule().module)
}
}
}
AppModule.kt
import org.koin.core.annotation.ComponentScan
import org.koin.core.annotation.Module
@Module
@ComponentScan("com.mysite")
class AppModule
logs.zip