颤振AndroidX不兼容如何手动设置依赖项 [英] Flutter & AndroidX incompatibility How to set a dependency manually
问题描述
由于AndroidX不兼容,编译时出现错误:
I'm getting error(s) while compiling due to AndroidX incompatibility:
Android依赖项"androidx.vectordrawable:vectordrawable"对于编译(1.0.0)和运行时(1.0.1)类路径具有不同的版本.您应该通过DependencyResolution手动设置相同的版本
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
遵循->这篇文章<-我在build.gradle中添加了一些代码
following -> this post <- I've added some code to build.gradle
allprojects {
configurations.all {
resolutionStrategy.force"androidx.vectordrawable:vectordrawable:1.0.0",
}
repositories {
google()
jcenter()
}
下次跑步给了我另一个错误
next run gave me this other error
Android依赖项"androidx.core:core"对于编译(1.0.0)和运行时(1.0.1)类路径具有不同的版本.您应该通过DependencyResolution手动设置相同的版本
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",
"androidx.vectordrawable:vectordrawable:1.0.0","androidx.core:core:1.0.0",
但是我可能做错了,因为我得到了经典的意外的bla bla bla".
but I'm probably doing it wrong, since I get the classical "unexpected bla bla bla"
有什么建议吗?
预先感谢
[edit]我也尝试过这个老把戏,但是没有用 (还会根据需要降级软件包此处 )
[edit] i've tried this old trick as well, but didn't work (also downgrading the packages as required 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依赖项"androidx.appcompat:appcompat"对于编译(1.0.0)和运行时(1.0.2)类路径具有不同的版本.您应该通过DependencyResolution手动设置相同的版本
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
推荐答案
- 在android/gradle/wrapper/gradle-wrapper.properties中,更改以distributionUrl开头的行,如下所示:distributionUrl = https://services.gradle.org/distributions/gradle-4.10.2-all.zip
2.在android/build.gradle中,替换:
2.In android/build.gradle, replace:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
作者
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
3.在android/gradle.properties中,添加
3.In android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
4.在android/app/build.gradle中:
4.In android/app/build.gradle:
在android {下,请确保compileSdkVersion和targetSdkVersion至少为28.
Under android {, make sure compileSdkVersion and targetSdkVersion are at least 28.
5.用AndroidX等效项替换所有不推荐使用的库.例如,如果您使用默认的.gradle文件,请进行以下更改:
5.Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default .gradle files make the following changes:
在android/app/build.gradle中
In android/app/build.gradle
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
作者
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
最后,在依赖项下替换
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'
这篇关于颤振AndroidX不兼容如何手动设置依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!