8

I've migrated my project to AndroidX cause i was having some errors, but now i'm receiving a loop of errors that the androidX class has a different version from the compile:

Android dependency 'androidx.fragment:fragment' has different version for the compile (1.0.0-rc01) and runtime (1.1.0-alpha04) classpath. You should manually set the same version via DependencyResolution 

And it's always a different a class, i've already tried implementing this code but every time i add a line it gives me other class different from the compile:

configurations.all {
    resolutionStrategy {
        force 'androidx.fragment:fragment:v4:1.1.0-alpha04'
    }
}
1
  • I just had the same problem in my project. Solved by checking dependency graph via ./gradlew app:dependencies to see which dependencies have the same dependency on different versions. In my case, it was Google services and Room.
    – alashow
    Jan 19, 2020 at 1:30

5 Answers 5

25

I've had similar issue, just solved it using this inside app/build.gradle

configurations.all {
    resolutionStrategy {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.core') {
                details.useVersion "1.0.1"
            }
            if (details.requested.group == 'androidx.lifecycle') {
                details.useVersion "2.0.0"
            }
            if (details.requested.group == 'androidx.versionedparcelable') {
                details.useVersion "1.0.0"
            }
            if (details.requested.group == 'androidx.fragment') {
                details.useVersion "1.0.0"
            }
            if (details.requested.group == 'androidx.appcompat') {
                details.useVersion "1.0.1"
            }
        }
    }
}
3
  • In case if anyone has a problem adding the above mentioned configutation into build.gradle file here is a gist gist.github.com/valekar/3e96d939af00c569fa1eec58b8082289 Dec 8, 2019 at 19:36
  • Thanks. It worked for me. I also added android.useAndroidX=true android.enableJetifier=true android.debug.obsoleteApi=true in the gradle.properties file
    – Hijibiji
    Apr 15, 2020 at 9:03
  • excellent, best answer out there for me, thanks!
    – 68060
    Nov 25, 2021 at 14:20
22

If the problem persists, you might want to upgrade the gradle version in android/build.grandle

Change:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

To:

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'//latest version
}

You should also update your Kotlin version.

0
0

I've resolved my error migrating my project to androidX in gradle.properties, and by Refactor => Migrate to AndroidX, and adding this code to my app/build.gradle:

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
0

I pasted this.../android/build.gradle (not .../android/app/build.grade) and that made the problem out:

subprojects {
    project.configurations.all {
    resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.core' &&
           !details.requested.name.contains('androidx')) {
        details.useVersion "1.0.1"
            }
    }
    }    
}
0

Changing my com.android.tools.build:gradle to version 3.3.1 fixed the issue for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.