gpt4 book ai didi

android - Flutter & AndroidX 不兼容 如何手动设置依赖

转载 作者:IT王子 更新时间:2023-10-29 07:09:16 24 4
gpt4 key购买 nike

由于 AndroidX 不兼容,我在编译时遇到错误:

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

正在关注 -> this post <-我在 build.gradle 中添加了一些代码

allprojects {

configurations.all {
resolutionStrategy.force"androidx.vectordrawable:vectordrawable:1.0.0",
}
repositories {
google()
jcenter()
}

下一次运行给了我另一个错误

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

我试着添加这个

"androidx.vectordrawable:vectordrawable:1.0.0","androidx.core:core:1.0.0",

但我可能做错了,因为我得到了经典的“unexpected bla bla bla”

有什么建议吗?

提前致谢

[edit] 我也试过这个老把戏,但没用(还根据需要降级软件包 HERE )

rootProject.allprojects {
project.configurations.all {
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"
}
}
}
}

现在返回一个不同的错误

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

最佳答案

  1. 在 android/gradle/wrapper/gradle-wrapper.properties 中更改以 distributionUrl 开头的行,如下所示:distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip

2.在android/build.gradle中,替换:

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

通过

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

3.在android/gradle.properties中追加

android.enableJetifier=true
android.useAndroidX=true

4.在android/app/build.gradle:

在android {下,确保compileSdkVersion和targetSdkVersion至少为28。

5.将所有弃用的库替换为 AndroidX 等效项。例如,如果您使用默认的 .gradle 文件,请进行以下更改:

在android/app/build.gradle

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

通过

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

最后在dependencies下替换

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

通过

androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

关于android - Flutter & AndroidX 不兼容 如何手动设置依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56494895/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com