Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All the AndroidX versions different from the compile

Tags:

flutter

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'
    }
}
like image 690
Lívia Castilholi Santiago Avatar asked Feb 25 '19 18:02

Lívia Castilholi Santiago


People also ask

What are AndroidX libraries?

The Android Extension Library, often known as AndroidX, is the new open-source project that is a significant upgrade to the original Android Support Library and can be used to develop, test, package version, and release libraries within Jetpack. The Android Jetpack libraries are part of the AndroidX namespace.

How can I change my Android version to AndroidX?

With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

Why do we need AndroidX?

AndroidX is a major improvement to the original Android Support Library, which is no longer maintained. androidx packages fully replace the Support Library by providing feature parity and new libraries.


2 Answers

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"
            }
        }
    }
}
like image 51
Kaboom Avatar answered Nov 17 '22 01:11

Kaboom


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.

like image 32
Maciej Pulikowski Avatar answered Nov 17 '22 03:11

Maciej Pulikowski