Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 720
Amir Avatar asked Oct 23 '18 11:10

Amir


2 Answers

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...

like image 68
prom85 Avatar answered Sep 23 '22 22:09

prom85


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
like image 39
2hamed Avatar answered Sep 25 '22 22:09

2hamed