我注意到我可以注释掉 implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
尽管我在我的应用程序中使用了 ConstraintLayout,但没有任何错误。
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
// implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment:2.3.3'
}
为什么没事? com.google.android.material 库是否也包含约束布局?
最佳答案
它确实来自 com.google.android.material:material:1.3.0
- 但是当你没有明确声明它时,你将根据版本 2.0.1
构建- 代替当前版本 2.0.4
.
只需运行 ./gradlew app:dependencies
看看它会解决一个不同的版本。
免责声明:我不确定为什么这些依赖关系过时了
...但通常可以排除它们,因此必须提供它们:
implementation ("com.google.android.material:material:1.3.0") {
exclude group: "androidx.annotation" // 1.0.1 < 1.1.0
exclude group: "androidx.appcompat" // 1.1.0 < 1.2.0
exclude group: "androidx.constraintlayout" // 2.0.1 < 2.0.4
exclude group: "androidx.core" // 1.2.0 < 1.3.2
exclude group: "androidx.fragment" // 1.0.0 < 1.3.0
exclude group: "androidx.lifecycle" // 2.0.0 < 2.3.0
exclude group: "androidx.recyclerview" // 1.0.0 < 1.1.0
exclude group: "androidx.transition" // 1.2.0 < 1.4.0
}
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
implementation "androidx.core:core:1.3.2"
implementation "androidx.fragment:fragment:1.3.0"
implementation "androidx.lifecycle:lifecycle-runtime:2.3.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.transition:transition:1.4.0"
至少 Maven Central 是这么说的。我假设没有副作用。
关于android - 为什么 'androidx.constraintlayout:constraintlayout' 可以省略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66470806/