所有AndroidX版本均不同于编译

Lív*_*ago 4 flutter

我将项目迁移到AndroidX,原因是我遇到了一些错误,但是现在我收到了一个错误循环,表明androidX类的版本与编译版本不同:

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 
Run Code Online (Sandbox Code Playgroud)

而且它总是一个不同的类,我已经尝试实现此代码,但是每次我添加一行代码时,它都会给我另一个不同于编译的类:

configurations.all {
    resolutionStrategy {
        force 'androidx.fragment:fragment:v4:1.1.0-alpha04'
    }
}
Run Code Online (Sandbox Code Playgroud)

Kab*_*oom 18

我有类似的问题,只是在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"
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)


Mac*_*ski 10

如果问题仍然存在,您可能要在android / build.grandle中升级gradle版本

更改:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}
Run Code Online (Sandbox Code Playgroud)

至:

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'//latest version
}
Run Code Online (Sandbox Code Playgroud)

您还应该更新您的Kotlin版本。


Lív*_*ago 0

我已经解决了在 gradle.properties 中将我的项目迁移到 androidX 时出现的错误,并通过 Refactor => Migrate to AndroidX,并将以下代码添加到我的 app/build.gradle 中:

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
Run Code Online (Sandbox Code Playgroud)