I have been playing the past few days with this guide from Google. However, after sorting quite a few issues, I ran into this one, and I'm not sure if this might be the correct way to proceed with it.
Currently, I'm working in the gsoc20/build-aab branch. I have created the AabCompiler.java Callable class (thinking for future refactor) where I run specific AAB tasks. It first creates an the build/aab/
folder, preparing the structure for the AAB module.
Following the tutorial, the first step involves compiling the resource files using AAPT2:
aapt2 compile \
project_root/module_root/src/main/res/drawable/Image1.png \
project_root/module_root/src/main/res/drawable/Image2.png \
-o compiled_resources/
So, in https://github.com/barreeeiroo/appinventor-sources/blob/gsoc20/build-aab/appinventor/buildserver/src/com/google/appinventor/buildserver/AabCompiler.java#L192 I do so. The res_compiled/
folder gets created at the build/
level, not in the aab/
one.
The next step is to link all resources and "generate" an APK with all protobuf-encoded files which can be extracted later. So, what I do is https://github.com/barreeeiroo/appinventor-sources/blob/gsoc20/build-aab/appinventor/buildserver/src/com/google/appinventor/buildserver/AabCompiler.java#L212. I don't use the res_compiled/*.flat
because the *
wildcard is not supported on Windows.
And here comes the problem.
When running ant PlayAppAab
(I just added that command to be able to test from command line) in that branch, errors like this start popping out:
error: style attribute 'attr/colorPrimary not found
And I found that it was because I did not have the attrs.xml file. So, I created it and started adding the attributes that were causing the errors: https://github.com/barreeeiroo/appinventor-sources/blob/gsoc20/build-aab/appinventor/buildserver/src/com/google/appinventor/buildserver/Compiler.java#L772
The first issues were quite easy to solve, as they were "attr" type. However, then I got the same issue but for textAllCaps. I made the same (boolean type), but then this error appeared:
Attribute "textAllCaps" already defined with incompatible format.
Then after checking this file I ended up removing the format and worked.
But I was not able to get rid of these errors:
[java] error: resource style/Theme.AppCompat.Light.Dialog.Alert (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog.Alert) not found.
[java] error: resource style/Theme.AppCompat.Light.Dialog.Alert (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog.Alert) not found.
[java] error: resource style/Theme.AppCompat.Light.Dialog.Alert (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog.Alert) not found.
[java] error: resource style/Theme.AppCompat.Light.Dialog.Alert (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog.Alert) not found.
[java] error: resource style/Theme.AppCompat.Light.Dialog (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog) not found.
[java] error: resource style/Theme.AppCompat.Light.Dialog (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog) not found.
[java] error: resource style/Theme.AppCompat.Light.Dialog (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog) not found.
[java] error: resource style/Theme.AppCompat.Light.Dialog (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.Dialog) not found.
[java] error: resource style/Theme.AppCompat.Light.DarkActionBar (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.DarkActionBar) not found.
[java] error: resource style/Theme.AppCompat.Light.DarkActionBar (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.DarkActionBar) not found.
[java] error: resource style/Theme.AppCompat.Light.DarkActionBar (aka edu.mit.appinventor.aicompanion3:style/Theme.AppCompat.Light.DarkActionBar) not found.
[java] error: resource style/Widget.AppCompat.CompoundButton.Switch (aka edu.mit.appinventor.aicompanion3:style/Widget.AppCompat.CompoundButton.Switch) not found.
[java] C:\Users\DIEGOB~1\AppData\Local\Temp\1592499516754_0.35972695033492474-0\youngandroidproject\..\build\res\values\styles.xml:10: error: resource drawable/abc_item_background_holo_light (aka edu.mit.appinventor.aicompanion3:drawable/abc_item_background_holo_light) not found.
[java] error: resource style/TextAppearance.AppCompat (aka edu.mit.appinventor.aicompanion3:style/TextAppearance.AppCompat) not found.
[java] error: resource style/TextAppearance.AppCompat (aka edu.mit.appinventor.aicompanion3:style/TextAppearance.AppCompat) not found.
[java] error: resource style/TextAppearance.AppCompat (aka edu.mit.appinventor.aicompanion3:style/TextAppearance.AppCompat) not found.
[java] error: resource style/TextAppearance.AppCompat (aka edu.mit.appinventor.aicompanion3:style/TextAppearance.AppCompat) not found.
[java] error: resource style/TextAppearance.AppCompat (aka edu.mit.appinventor.aicompanion3:style/TextAppearance.AppCompat) not found.
[java] error: failed linking references.
So, I am wondering if following that guide is the correct way to proceed, because they actually build a fake APK and then unpack it to extract the protocol-buffered files, so they can place it in the zip module to run bundletool.