18

I've got this compile error! I checked similar problems on stackoverflow but all of them were about different errors & not " attr/orientation' with config '' ", but they didn't work for my problem! I'm using androidx library , kotlin ,Gradle 4.10.1 ,

I do these steps, but still no result:

1- Clean Project

2- Rebuild

3- Invalidate caches / Restart

4- made another attrs.xml file on the folder : res->values-v21

5-so many other ways...

but all of them just failed! Any solution?

Hamed Jaliliani
  • 2,789
  • 24
  • 31

2 Answers2

48

I find the problem, it is a bug and I reported it to Google ( b.android.com ) & they answered

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

.

So how to solve it: I faced the problem when updated to alpha3 version of library in build.gradle (Module) :

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

Just downgrade it to lower version:

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

and now it's ok.

The problem was the conflict between constraintlayout:2.0.0-alpha3 library and attrs.xml merging on compile time!

and for you it might be just conflicts between some other libraries ( just check last updated libraries )

Hamed Jaliliani
  • 2,789
  • 24
  • 31
  • 3
    True. You can raise the issue as google bug, it seems to happen to a lot of users – usernotnull Dec 23 '18 at 06:23
  • 2
    Tnx @RJFares, I reported it as a bug on b.android.com , and they answered: We're aware of this bug & will be OK on the next alpha version – Hamed Jaliliani Dec 24 '18 at 12:04
  • 1
    I was so confused by this error and you saved my ass and hair. Merry Christmas btw. – Jack Dec 25 '18 at 07:16
  • @jackz314 this bug waste almost one day of mine! Merry Christmass :) – Hamed Jaliliani Dec 25 '18 at 07:21
  • helped me too https://stackoverflow.com/questions/53978229/android-resource-compilation-failed-error-duplicate-value-for-resource-attr-o – user25 Dec 30 '18 at 14:35
  • In case you created a custom "Orientation" styleable attribute in attrs.xml, just rename it to e. g. "CustomOrientation". Don't forget to update your code and XMLs where the attribute is used. After cleaning the project the build finished successfully. In case of a clash with a 3rd party library downgrading to 2.0.0-alpha2 is probably the only option. – Miloš Černilovský Jan 17 '19 at 12:45
  • Ah! Version conflict always would be a problem. – Artin Falahi Jan 22 '19 at 08:33
2

It happens if you are you have migrate to Androidx and you add android.support library. Just try to find Androidx library for the android.support library you are using. For example. Change

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

To

implementation 'androidx.cardview:cardview:1.0.0'

SilenceCodder
  • 2,874
  • 24
  • 28