Status Update
Comments
gk...@uber.com <gk...@uber.com> #2
Can we please raise the priority of this?
gk...@uber.com <gk...@uber.com> #3
happening on build tools 27.0.0, 27.0.1 and 27.0.3 as well
yo...@uber.com <yo...@uber.com> #4
This is an issue for us too, please prioritize this.
ad...@google.com <ad...@google.com> #6
Can you upload a small project that reproduces the issue?
to...@gmail.com <to...@gmail.com> #7
Well it's just adding a button in default app ;) Anyway see attachment.
Just press run and see the crash. Disable aapt2 and see the button :)
Just press run and see the crash. Disable aapt2 and see the button :)
ad...@google.com <ad...@google.com> #8
Ah I've figured it out.
This library was built with very old build-tools, a version that had a bug where the styleable indices would be generated as final, and therefore inlined. AAPT2 assigns resources with a different order, and therefore, causes a mismatch between the final R class and some inlined constants in the library dex.
Ex:
Bad R.java:
public class R {
public static class styleable {
public static int[] ProgressButton = new int[] {0x01010001, ...};
public static final int ProgressButton_android_background = 0;
...
The index will be inlined, even if the order of the final array changes.
Please rebuild the library, or ask the author to re-build the library and re-publish with newer build-tools.
This library was built with very old build-tools, a version that had a bug where the styleable indices would be generated as final, and therefore inlined. AAPT2 assigns resources with a different order, and therefore, causes a mismatch between the final R class and some inlined constants in the library dex.
Ex:
Bad R.java:
public class R {
public static class styleable {
public static int[] ProgressButton = new int[] {0x01010001, ...};
public static final int ProgressButton_android_background = 0;
...
The index will be inlined, even if the order of the final array changes.
Please rebuild the library, or ask the author to re-build the library and re-publish with newer build-tools.
to...@gmail.com <to...@gmail.com> #9
Thanks will try and report back but I've searched a lot about this issue since a long time before disabling aapt2 before.
Would be nice if aapt2 could detect that and give an error at build time instead of an error at run time that could be quite hard to track or find.
Would be nice if aapt2 could detect that and give an error at build time instead of an error at run time that could be quite hard to track or find.
to...@gmail.com <to...@gmail.com> #10
So can confirm it was the issue, but I really think having something to help devs at compilation time would greatly improve experience as those runtime changes are complicated to identify.
ad...@google.com <ad...@google.com> #11
I understand, and agree, however, since the AAR doesn't ship with the R.java class it was compiled with, the check would have to do bytecode analysis to guess if inlined styleable indices were used, which is not always accurate.
to...@gmail.com <to...@gmail.com> #12
Well would be cool to have some doc somewhere about this issue then.
I'm sure lot's of users like me did have problems when 3.0 was out and aapt2 becomes default and disabled aapt2 after readinghttps://developer.android.com/studio/build/gradle-plugin-3-0-0.html but with 3.1 and the deprecation message they will try again and be lost at finding how to fix this.
And the fix is actually quite simple just need the dev to be aware.
I'm sure lot's of users like me did have problems when 3.0 was out and aapt2 becomes default and disabled aapt2 after reading
And the fix is actually quite simple just need the dev to be aware.
ad...@google.com <ad...@google.com> #13
I've filed b/74239916 for this.
to...@gmail.com <to...@gmail.com> #14
Thanks.
ra...@gmail.com <ra...@gmail.com> #15
Is there a way to detect this issue given an aar? we have a lot of external dependencies and is not feasible to find out the broken one.
Some guidelines would be really useful. Thanks!
Some guidelines would be really useful. Thanks!
Description
Gradle version:
Select File > Project Structure, click Project, and then locate Gradle version.
Android Plugin Version:
On the same page as the Gradle version, locate Android Plugin Version.
Occurs with 3.0.1 and 3.1.0-beta3
Module Compile Sdk Version:
From the above page, select your module in the left pane and locate Compile Sdk Version.
27.0.3 but with previous too
Module Build Tools Version:
From the above page, locate Build Tools Version.
Android SDK Tools version:
Select Tools > Android > SDK Manager, click SDK Tools, and then locate Android SDK Tools
All version since plugin 3.0-alphas
Ocurred since a long time but since disabling aapt2 solved it I forget to report and now disabling aap2 is deprecated it will become an issue.
Using the library
Caused by: android.content.res.Resources$NotFoundException: Resource "org.leetzone.android.yatsewidgetfree:dimen/progress_inner_size" (7f070104) is not a Drawable (color or path): TypedValue{t=0x5/d=0x1c01 a=3 r=0x7f070104}
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:737)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:621)
at android.content.res.Resources.getDrawable(Resources.java:1640)
at android.content.res.Resources.getDrawable(Resources.java:1611)
at com.f2prateek.progressbutton.ProgressButton.<init>(ProgressButton.java:1147)
at com.f2prateek.progressbutton.ProgressButton.<init>(ProgressButton.java:111)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:652)
The issue is that this resource as it's name implies is a dimension and not a drawable at all. (And correctly referenced as a dimension in R)
I tried adding in main app dimensions the dimension definition
<dimen name="progress_inner_size">28dp</dimen>
But this did not solved the issue.
I haven't found a workaround for this problem so unable to compile release with aapt2 currently.