Status Update
Comments
jg...@google.com <jg...@google.com>
je...@google.com <je...@google.com>
lu...@google.com <lu...@google.com> #2
I tried compiling a single color resource with the example hex value in comment 1 with the kotlin resource compiler and AAPT2 (version 34). Both failed as expected.
I will begin reproducing using the github project.
ev...@gmail.com <ev...@gmail.com> #3
Very interesting! It's possible that we're using an outdated setup which allows this to be possible.
It's good to hear that this might not be an issue going forward, at least :)
lu...@google.com <lu...@google.com> #4
#0xFFBB86FC -> build (AGP 7.4.2) fails [expected], aapt2 (34.0.0) fails [expected]
#blah -> build (AGP 7.4.2) success [not expected], fails with AAPT2 [expected]
##0xE1E1E1 -> build (AGP 7.4.2) success [not expected], fails with AAPT2 (34.0.0) [expected]
I'll take a look at our resource compilation error catching in AGP, as it might be ignoring AAPT fails. Another possibility is there is a mismatch (or bug rather) between the JVM resource compiler.
Although #0xFFBB86FC is compiling successfully in on my machine in the repro project, differing bug; but it does look like there are problems in this area.
ev...@gmail.com <ev...@gmail.com> #5
That's great! Thanks for the confirmation :)
lu...@google.com <lu...@google.com> #6
So the issue seems to be that the JVM (or Kotlin based) resource compiler sets the resource value of a color value resource to NULL rather than throwing an exception.
All that needs to be done here is to throw an exception when this is the case, so we can keep parity with AAPT behaviour.
Description
The short version: there's no error raised for something like this:
#0xFFBB86FC
is not a valid hex code, and should not be allowed to be compiled. Instead, the app compiles successfully and fails at runtime. I've made tiny little demo app here: