Amir
Amir

Reputation: 567

Migrating to AndroidX

I upgraded my Android Studio to 3.2 and now I want to auto migrate to AndroidX using from Redactor->Migrate to AndroidX and now it has this error:

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

Upvotes: 11

Views: 13230

Answers (4)

Jhakiz
Jhakiz

Reputation: 1609

I had the same issue, and i resolved it by using :

buildscript {
    ext{
        kotlin_version = '1.3.0' // Old 1.2.71
    ...
}

Endly i changed gradle version from 3.2.1 to 3.3.1:

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.0.1'
...

I hope this will help.

Upvotes: 0

2hamed
2hamed

Reputation: 9047

Probably one of your dependencies uses androidx.media:media:1.0.0-rc1. You should use Gradle's Dependency Resolution Strategy to force all dependencies to use the same version.
Try to add the following code in your app level build.gradle and it should work.
Something like this:

android {
    compileSdkVersion 28

    defaultConfig {
       // Your code
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
       // Your build types if any
    }

    configurations.all {
        resolutionStrategy {
            force 'androidx.media:media:1.0.0'
        }
    }
}

You can also use this command to detect which of your dependencies uses androidx.media:media:

./gradlew :app:dependencies

Upvotes: 16

prom85
prom85

Reputation: 17798

Refactoring will change old imports to following:

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

You may want to use following instead if you do not plan to use legacy dependencies:

implementation 'androidx.appcompat:appcompat:1.0.0'

This will remove the issue as well if you are not using media at all...

Upvotes: 4

Stanislav Mukhametshin
Stanislav Mukhametshin

Reputation: 853

Try to fix it manually.

Just change dependency to:

androidx.media:media:1.0.0

And change imports in your classes

Upvotes: 2

Related Questions