Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle | Android | Duplicate class androidx.work issue | androidx.workmanager

Execution failing when trying to build, Below is the error

Execution failed for task ':app:checkReleaseDuplicateClasses'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable Duplicate class androidx.work.OneTimeWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.1-runtime (androidx.work:work-runtime-ktx:2.7.1) Duplicate class androidx.work.PeriodicWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.1-runtime (androidx.work:work-runtime-ktx:2.7.1)

 Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

I tried force setting the version to 2.8.1 as its the latest stable version.

implementation("androidx.work:work-runtime-ktx:2.7.1:$androidxWorkWork"){ force = true }

defined $androidxWorkWork = "2.8.1"

Expected the classes would pick 2.8.1, but i see a new error where a particular package was not found.

Execution failed for task ':app:checkReleaseDuplicateClasses'.

Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. Failed to transform work-runtime-ktx-2.7.1-2.8.1.jar (androidx.work:work-runtime-ktx:2.7.1) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Could not find work-runtime-ktx-2.7.1-2.8.1.jar (androidx.work:work-runtime-ktx:2.7.1). Searched in the following locations: https://nexus.rbfcu.org/repository/maven-public/androidx/work/work-runtime-ktx/2.7.1/work-runtime-ktx-2.7.1-2.8.1.jar

Below are the dependencies of the app in build.gradle

dependencies {
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0"
implementation("androidx.work:work-runtime-ktx:2.7.1:$androidxWorkWork"){
force = true


Env: Ionic + Angular

Any suggestions on what can be done?

like image 889
Rohitb Avatar asked Jul 22 '26 22:07

Rohitb


1 Answers

I was able to solve it just by adding this line to the project's level build.gradle file

configurations {
    all {
        exclude group: 'androidx.work', module: 'work-runtime-ktx'
    }
}
like image 177
MohKoma Avatar answered Jul 25 '26 16:07

MohKoma