zmattr
(Matt Robertson)
February 18, 2021, 3:55pm
1
Trying again to get aapt2 working for Android projects… On a new project, when I enable aapt2 and build, I get errors about R.java being unknown. When I compare the intermediate outputs from aapt and aapt2 I see that it is in a different folder. I’m not sure if this is an aapt/aapt2 difference or if EBuild is providing a different path, but aapt it placing it directly in the java folder and aapt2 is placing it in a package hierarchy within the java folder.
aapt:
Cooper-Android
- java
- R.java
aapt2:
Cooper-Android
- java
- org
- gradletest
- R.java
zmattr
(Matt Robertson)
February 18, 2021, 4:42pm
2
After looking at the code, EBuild just passes the “java” folder as the --java
argument for aapt or aapt2, so aapt2 must create a package folder hierarchy whereas aapt did not. The problem is that R.java
is not discovered when it is in aapt2’s package hierarchy structure. I’m not sure whether that is an EBuild issue, a compiler issue, or a Fire/Water issue though.
mh
(marc hoffman)
February 18, 2021, 4:59pm
3
Sounds like an EBuild issue. I’ll have a look… This did work at some stage.
mh
(marc hoffman)
February 18, 2021, 5:01pm
4
Can I get a testcase for this,. though? a new Android project compiles clean for me with aapt2, including the line ContentView := R.layout.main;
which depends on R.java. The IDE also sees the generated file just fine:
zmattr
(Matt Robertson)
February 18, 2021, 6:02pm
5
Ah interesting. I don’t have “Generated Source Files” in my IDE.
org.gradletest 2.zip (43.7 KB)
mh
(marc hoffman)
February 18, 2021, 6:35pm
6
The build needs to succeed a least once for that to get populated
mh
(marc hoffman)
February 18, 2021, 6:50pm
7
reproduced & fixed; it didn’t check the ./java folder recursively.
20210218-185000-elements-develop or later will have the fix.
1 Like
zmattr
(Matt Robertson)
February 19, 2021, 2:19pm
8
First time downloading on a Mac. And a first time Mac user in general How do I download and set up from the downloads page for a Mac?
mh
(marc hoffman)
February 19, 2021, 2:20pm
9
1 Like
zmattr
(Matt Robertson)
February 19, 2021, 5:10pm
10
Confirmed this works for me as well
1 Like
zmattr
(Matt Robertson)
February 19, 2021, 6:54pm
11
I am able to build & run a new project with aapt2 now, but I get 20 errors building when including appcompat library. They are coming from aapt2, but again this works fine in Android Studio so it looks like EBuild must be calling aapt2 incorrectly
These are the errors:
E: aapt2 link: resource color/androidx_core_secondary_text_default_material_light (aka org.gradletest:color/androidx_core_secondary_text_default_material_light) not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/core-1.3.2/res/values-v21/values-v21.xml (3)]
E: aapt2 link: resource style/Base.V7.Theme.AppCompat.Dialog (aka org.gradletest:style/Base.V7.Theme.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.V21.Theme.AppCompat.Dialog (aka org.gradletest:style/Base.V21.Theme.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.Theme.AppCompat.Dialog.FixedSize (aka org.gradletest:style/Base.Theme.AppCompat.Dialog.FixedSize) not found.
E: aapt2 link: resource style/Base.V7.Theme.AppCompat.Light.Dialog (aka org.gradletest:style/Base.V7.Theme.AppCompat.Light.Dialog) not found.
E: aapt2 link: resource style/Base.V21.Theme.AppCompat.Light.Dialog (aka org.gradletest:style/Base.V21.Theme.AppCompat.Light.Dialog) not found.
E: aapt2 link: resource style/Base.Theme.AppCompat.Light.Dialog.FixedSize (aka org.gradletest:style/Base.Theme.AppCompat.Light.Dialog.FixedSize) not found.
E: aapt2 link: resource style/Base.V7.ThemeOverlay.AppCompat.Dialog (aka org.gradletest:style/Base.V7.ThemeOverlay.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.V21.ThemeOverlay.AppCompat.Dialog (aka org.gradletest:style/Base.V21.ThemeOverlay.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.V21.Theme.AppCompat (aka org.gradletest:style/Base.V21.Theme.AppCompat) not found.
E: aapt2 link: style attribute 'attr/actionModeShareDrawable (aka org.gradletest:attr/actionModeShareDrawable)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (6)]
E: aapt2 link: style attribute 'attr/editTextBackground (aka org.gradletest:attr/editTextBackground)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (8)]
E: aapt2 link: resource style/Base.V21.Theme.AppCompat.Light (aka org.gradletest:style/Base.V21.Theme.AppCompat.Light) not found.
E: aapt2 link: style attribute 'attr/actionModeShareDrawable (aka org.gradletest:attr/actionModeShareDrawable)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (11)]
E: aapt2 link: style attribute 'attr/editTextBackground (aka org.gradletest:attr/editTextBackground)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (13)]
E: aapt2 link: style attribute 'attr/ratingBarStyleIndicator (aka org.gradletest:attr/ratingBarStyleIndicator)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (9)]
E: aapt2 link: style attribute 'attr/ratingBarStyleSmall (aka org.gradletest:attr/ratingBarStyleSmall)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (10)]
E: aapt2 link: style attribute 'attr/actionBarItemBackground (aka org.gradletest:attr/actionBarItemBackground)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (13)]
E: aapt2 link: style attribute 'attr/actionMenuTextColor (aka org.gradletest:attr/actionMenuTextColor)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (15)]
E: aapt2 link: style attribute 'attr/actionMenuTextAppearance (aka org.gradletest:attr/actionMenuTextAppearance)' not found. [/Users/mattr/Library/Application Support/RemObjects Software/EBuild/Obj/org.gradletest-3D6480681C20545BA18D88CF7E85BCC8BBA0DE31/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (16)]
Here is the complete build log:
aapt2_build.txt (447.9 KB)
zmattr
(Matt Robertson)
February 19, 2021, 7:37pm
13
mh:
do those exist?
They exist within appcompat, but it looks like aapt2 is looking for them within my project
style/Base.V21.Theme.AppCompat.Light.Dialog (aka org.gradletest:style/Base.V21.Theme.AppCompat.Light.Dialog)
This should not be scoped to my project (org.gradletest
)
zmattr
(Matt Robertson)
February 24, 2021, 2:47pm
14
Still getting this when including appcompat on a new project building with aapt2. Just wanted to make sure it wasn’t dropped
mh
(marc hoffman)
February 24, 2021, 3:05pm
15
Not really sure what to do about it at this point, TBH :(. can I get a simple test case for this?
zmattr
(Matt Robertson)
February 24, 2021, 3:16pm
16
This is a new project with the following changes:
Targeting api 29.
Renamed .android-xml files to .xml
Added appcompat:[1.2.0]
It fails with the above error in aapt2 but builds successfully if you either swap to aapt or remove appcompat.
com.aapt2.tests.zip (43.6 KB)
zmattr
(Matt Robertson)
February 24, 2021, 10:53pm
17
Is there any way I can help speed this up? Testing? Looking into EBuild code myself? Manually calling aapt2? I haven’t been able to build my project for a week and have a huge deadline to release end of next week, and it looks like I have to move to aapt2 to get my project building (due to the other unfixed bugs I’ve been reporting).
mh
(marc hoffman)
February 24, 2021, 11:39pm
18
I can repro the issue, but TBH I’m out of ideas what to look at. aapt is a black box to me; we pass in all the refs, ours comes the result. Maybe you can find out how Android Studio/gradle calls it, and see if it passes any other parameters that might be relevant?
1 Like
zmattr
(Matt Robertson)
February 25, 2021, 3:58pm
19
Finally able to build using the right configuration of libraries and Oxygene compiler versions. So this is not a critical issue for me now, although EBuild really does need to support aapt2 if Google is now releasing libraries that require it.
That said, I found this aapt2 doc article last night that lists behavior changes from aapt to aapt2. One of the changes says that trying to use a resource name to indicate the type (e.g. name="attr/my_attr"
rather than type="attr" name="my_attr"
) will cause the following error:
Error: style attribute 'attr/attr/my_attr (aka my.package:attr/attr/my_attr)'
not found.
This looks very similar to the errors that I’m getting from appcompat with aapt2. I also found that there is a --legacy
flag on the aapt2 compile
command that causes these behavior changes from aapt to aapt2 to register as warning rather than errors. When I tried manually running aapt2 compile & link with this flag I still got the errors, but it may be worth trying it in EBuild as I may have been calling it incorrectly.
mh
(marc hoffman)
February 25, 2021, 5:32pm
20
What changed/what did you have to change? with aapt
or aapt2
?
agreed, yes.
Indeed it does. question is who’s error is this, if aapt2
flags it? the aapt2
user’s (ie us/ebuild for using it wrong) or the library creator (for having bad xml)? It sounds like the latter, ie the error is valid , and the lib needs to be updated for aapt2
?
zmattr:
I also found that there is a --legacy
flag on the aapt2 compile
command that causes these behavior changes from aapt to aapt2 to register as warning rather than errors. When I tried manually running aapt2 compile & link with this flag I still got the errors, but it may be worth trying it in EBuild as I may have been calling it incorrectly.
I’ll add --legacy
to EBuild now;’ if that fixes the issue, good, and we can review whether to keep the switch or add an option for it, later?
Update :
adding that switch gives me more errors, not fewer:
E: aapt2 link: resource style/Base.V7.Theme.AppCompat.Dialog (aka com.aapt2.tests:style/Base.V7.Theme.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.V21.Theme.AppCompat.Dialog (aka com.aapt2.tests:style/Base.V21.Theme.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.Theme.AppCompat.Dialog.FixedSize (aka com.aapt2.tests:style/Base.Theme.AppCompat.Dialog.FixedSize) not found.
E: aapt2 link: resource style/Base.V7.Theme.AppCompat.Light.Dialog (aka com.aapt2.tests:style/Base.V7.Theme.AppCompat.Light.Dialog) not found.
E: aapt2 link: resource style/Base.V21.Theme.AppCompat.Light.Dialog (aka com.aapt2.tests:style/Base.V21.Theme.AppCompat.Light.Dialog) not found.
E: aapt2 link: resource style/Base.Theme.AppCompat.Light.Dialog.FixedSize (aka com.aapt2.tests:style/Base.Theme.AppCompat.Light.Dialog.FixedSize) not found.
E: aapt2 link: resource style/Base.V7.ThemeOverlay.AppCompat.Dialog (aka com.aapt2.tests:style/Base.V7.ThemeOverlay.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.V21.ThemeOverlay.AppCompat.Dialog (aka com.aapt2.tests:style/Base.V21.ThemeOverlay.AppCompat.Dialog) not found.
E: aapt2 link: resource style/Base.V21.Theme.AppCompat (aka com.aapt2.tests:style/Base.V21.Theme.AppCompat) not found.
E: aapt2 link: style attribute 'attr/actionModeShareDrawable (aka com.aapt2.tests:attr/actionModeShareDrawable)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (6)]
E: aapt2 link: style attribute 'attr/editTextBackground (aka com.aapt2.tests:attr/editTextBackground)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (8)]
E: aapt2 link: resource style/Base.V21.Theme.AppCompat.Light (aka com.aapt2.tests:style/Base.V21.Theme.AppCompat.Light) not found.
E: aapt2 link: style attribute 'attr/actionModeShareDrawable (aka com.aapt2.tests:attr/actionModeShareDrawable)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (11)]
E: aapt2 link: style attribute 'attr/editTextBackground (aka com.aapt2.tests:attr/editTextBackground)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v22/values-v22.xml (13)]
E: aapt2 link: style attribute 'attr/ratingBarStyleIndicator (aka com.aapt2.tests:attr/ratingBarStyleIndicator)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (9)]
E: aapt2 link: style attribute 'attr/ratingBarStyleSmall (aka com.aapt2.tests:attr/ratingBarStyleSmall)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (10)]
E: aapt2 link: style attribute 'attr/actionBarItemBackground (aka com.aapt2.tests:attr/actionBarItemBackground)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (13)]
E: aapt2 link: style attribute 'attr/actionMenuTextColor (aka com.aapt2.tests:attr/actionMenuTextColor)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (15)]
E: aapt2 link: style attribute 'attr/actionMenuTextAppearance (aka com.aapt2.tests:attr/actionMenuTextAppearance)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (16)]
E: aapt2 link: style attribute 'attr/actionOverflowButtonStyle (aka com.aapt2.tests:attr/actionOverflowButtonStyle)' not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.aapt2.tests-73B40965F6921399E445509C67EEDB2FEAB9952A/Debug/Cooper-Android/aar/appcompat-1.2.0/res/values-v23/values-v23.xml (17)]