garretyoder/Colorful

Compile issue error: style attribute 'attr/colorSecondary

bmbariah opened this issue · 11 comments

I'm getting the error with the latest build 2.3.3 in my compiler
error: style attribute 'attr/colorSecondary (aka com.***.**:attr/colorSecondary)' not found.
Errors are pointing to the values.xml file in Colorful lib specifically accent1 to accent 20

Kindly assist.
I'm on android support lib 27.1.1

Is this an actual compile time error that stops compilation or merely a warning? Colorful sets several different values to ensure maximum compatibility with all devices/platforms, some of which not all platforms will support, and throw a warning informing you of this.

Also, post your usage of colorful, such as any style files, initialization code, etc. There is nowhere colorful uses any attr/ values as they are unreliable. Are you using it anywhere?

It stops compilation and is not just a warning. I've only added the implementation line in my gradle file.
Any attempts to add colorSecondary as an attr have failed

Why and where are you using colorsecondary as a attr? Please post where you're using it. I suspect, if you remove the colorful dependency you will still get the same error because it's unrelated to colorful.

If i remove the colorful dependency it compiles successfully. I only tried to add the colorSecondary as an attempt to solve the issue

It compile successfully with release 2.1 but not latest 2.3.3

colorsecondary is a valid style item that colorful sets to keep compatibility with the new material components widgets, however it is not commonly a valid attr that you can use in xml unless you're targeting sdk28.

If you're not targeting sdk28 you should be using colorAccent as your attr to retrieve the color in xml.

I can test this issue tonight, but let me make sure I'm clear on what's happening.

You run into a compile error merely by adding colorful as a dependency. No xml attrs anywhere, no initialization code, no using colorful's themes, etc.

You run into a compile error merely by adding colorful as a dependency. No xml attrs anywhere, no initialization code, no using colorful's themes, etc.

Exactly...just the one line in gradle

I will test this issue tonight on your exact sdk version and get back to you.

However, I suspect this isn't a issue caused by colorful, simply because colorful is extremely simple, it's just a collection of style files. Colorful's stable branch, which you're using, even compiles on sdk 27 and links the same version of appcompat you're using for it's release build. https://github.com/garretyoder/Colorful/blob/master/library/build.gradle

I think I've found the issue, it's neither a issue with Colorful nor your setup, but a change in how AAPT2 handles warnings in certain scenarios. This was a undocumented change a couple months ago. Basically, in certain cases, AAPT2 will throw a error and stop compilation instead of throwing a warning like normal. This is something I can fix with some build tweaks to have it ignore it in these cases, and will publish in a release later today.

I've fixed the issue on my end with some build changes. Please pull down the latest commit and test to see if your issue is fixed.

implementation 'com.github.garretyoder:Colorful:-SNAPSHOT' to use the latest commit.

If this fixes your issue I will push it as a stable release.

It worked. Successfully compiled in my end and everything else works great.

Thanks for all your hard work !