I try to understand how a .apk file is built from source code. I know that with Android Studio or with the command gradlew the build can be done easily. The Android Sdk provides multiple tools that are used to build a .apk, which most of them I know what they do:
d8: java byte code to dalvik bytecode
aapt2: Compile resources and link them. This tool creates a .apk file of compiled resources. (It also creates R.java to reference the resources in the code.)
apksigner: Takes the .apk and signs it. Otherwise, it cannot be installed on an Android device.
zipalign: aligns uncompressed data of the .apk
The last two tools are used on the apk, which already contains all files. What I do not understand is how compiled code and compiled resources are combined? Before aapt2 was a thing the packaging was done with aapt, but it is not even listed on Androids Documentation. However, aapt is still in the Android Sdk build-tools. The new aapt2 has no option for packaging.
So, the question is which command-line tools and in which order are used to create a complete .apk from source code? Thank you!
EDIT: What I am looking for would be similar to this, where a .apk is created with the command-line step by step. Only the answer uses the old aapt, which I think is not used anymore.
EDIT 2:
Thanks to Allen Shaw for giving me the missing information. I was now able to compile an app with aapt2. The answer to my question was simply to zip the aapt2 output and the classes.dex.