error: duplicate value for resource 'attr/orientation' with config '' .aapt.v2.Aapt2Exception: Android resource compilation failed

error: duplicate value for resource 'attr/orientation' with config '' .aapt.v2.Aapt2Exception: Android resource compilation failed

我有这个编译错误! 我在 Whosebug 上检查了类似的问题,但它们都是关于不同的错误,而不是“ attr/orientation' with config '' ”,但它们对我的问题不起作用! 我正在使用 androidx 库,kotlin,Gradle 4.10.1,

我做了这些步骤,但仍然没有结果:

1- 清理项目

2-重建

3- 使缓存无效/重新启动

4- 在文件夹中创建了另一个 attrs.xml 文件:res->values-v21

5-这么多其他方式...

但他们都失败了! 有什么解决办法吗?

我发现了问题,这是一个错误,我将其报告给 Google ( b.android.com ),他们回答了

Yep, we are aware of this issue, it will be fixed in the next alpha release. this is the : issue link

.

那么如何解决呢: 我在 build.gradle(模块)中更新到 alpha3 版本的库时遇到了问题:

  implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3' 

降级到低版本即可:

  implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2' 

现在好了。

问题是 constraintlayout:2.0.0-alpha3 库和 attrs.xml 在编译时合并之间的冲突!

对您来说,这可能只是其他一些库之间的冲突(只需检查最近更新的库)

如果您迁移到 Androidx 并添加了 android.support 库,就会发生这种情况。只需尝试为您正在使用的 android.support 库找到 Androidx 库。 例如。 变化

implementation 'com.android.support:cardview-v7:28.0.0'

implementation 'androidx.cardview:cardview:1.0.0'