这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@birhburh
Copy link

@birhburh birhburh commented Mar 8, 2025

It seems that after #21562 aapt couldn't properly parse resources.arsc provided with android-35 platform
Updated it to 15.0.0.23
Fixes #21666
Didn't checked myself but probably also:
Fixes #22712
Fixes #22667


using CXXFLAGS+=" -fPIC -std=gnu++2b" because it used in base/libs/androidfw/Android.bp and fails with strange template errors on previous versions

Copy link
Member

@TomJo2000 TomJo2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must have been a ton of effort.
Thank you a lot for your contribution.

I assume you have already done local/on-device testing,
but for anyone else reading this who may want to test this before it is merged I will leave instructions below.


(This is a pre-written, saved reply.)
If you want to test this PR please download the appropriate DEB package(s)
from the build artifacts of the associated PR's latest CI run.
Screenshot_20240619_232413

After downloading the build artifact, make sure to unzip and un-tar it.

Detailed instructions, if needed.

# finding out what architecture you need
# architecture is just below the TERMUX_VERSION
termux-info

# e.g.
# [...]
# TERMUX_MAIN_PACKAGE_FORMAT=debian
# TERMUX_VERSION=0.118.0
# TERMUX__USER_ID=0
# Packages CPU architecture:
# aarch64
# [...]

# =======================

# make sure `unzip` and `tar` are installed using
pkg install unzip tar

# unzip the artifact (if you have a different architecture this might be arm, i686 or x86_64 instead)
unzip debs-aarch64-*.zip

# untar the artifact
tar xf debs-aarch64-*.tar

# You should now have a debs/ directory in your current working directory
# Install the packages from the local source using
pkg install -- ./debs/*.deb

# to clean up, you can remove the debs/ directory, .tar file and .zip file
rm -rfi debs debs-aarch64-*.zip debs-aarch64-*.tar

@birhburh
Copy link
Author

birhburh commented Mar 8, 2025

Ok, will fix and check arm and i686 fails tomorrow

@Biswa96
Copy link
Member

Biswa96 commented Mar 8, 2025

I was planning to replace the files in the aapt directory with https://github.com/termux/android-build-tools project.

@birhburh
Copy link
Author

birhburh commented Mar 8, 2025

@Biswa96
It will be really awesome!
But probably will be a burden to catchup with AOSP changes in the future
Better then the current process of course

@Biswa96
Copy link
Member

Biswa96 commented Mar 8, 2025

But probably will be a burden to catchup with AOSP changes in the future

I am sending simple patches to upstream, for example https://android-review.googlesource.com/c/platform/frameworks/native/+/3526633 and will try to simplify the maintenance.

@MohammadKHC
Copy link
Contributor

Any update??

Btw thanks for your work guys. I really appreciate it.

@birhburh
Copy link
Author

@MohammedKHC0
Currently you can download artifacts as described in this comment
I tested that it works on armv7 and aarch64 now
Unzip it on your computer or on device and
And install needed deb package using:

apt install PATH_TO_DEB

on your device

@Anonymous2716
Copy link

Anonymous2716 commented Mar 16, 2025

the command aapt2 of aarch64 arch artifact gives:

CANNOT LINK EXECUTABLE "aapt2": cannot locate symbol "png_sig_cmp" referenced by "/data/data/com.termux/files/usr/lib/libandroid-fw.so"...

@twaik
Copy link
Member

twaik commented Apr 18, 2025

the command aapt2 of aarch64 arch artifact gives:

CANNOT LINK EXECUTABLE "aapt2": cannot locate symbol "png_sig_cmp" referenced by "/data/data/com.termux/files/usr/lib/libandroid-fw.so"...

Probably the branch should be rebased against current master.

@MohammadKHC
Copy link
Contributor

the command aapt2 of aarch64 arch artifact gives:

CANNOT LINK EXECUTABLE "aapt2": cannot locate symbol "png_sig_cmp" referenced by "/data/data/com.termux/files/usr/lib/libandroid-fw.so"...

Is this fixed?

@MohammadKHC
Copy link
Contributor

@twaik @birhburh Sorry for the ping but is there is any work begining done?
Also please tell me if there is anyway i can help. Aapt is really needed at many IDEs for Android.

@birhburh
Copy link
Author

@MohammedKHC0
Will try to fix it today

@birhburh
Copy link
Author

birhburh commented May 24, 2025

Fixed this linking error, but it segfaults now at startup, will continue tomorrow

@birhburh
Copy link
Author

birhburh commented Jun 29, 2025

@MohammedKHC0

Last commit should fix aapt2
It works for me on waydroid
at least no segfault on start and it shows help
Will test on real devices and update this comment: works on arm64 device, works on arm32 device
I think, rerun of CI needed for new artifacts

If you don't want to wait for new artifacts
Clone my repo (or fetch this pr branch for this repo) and run for arm64:

./scripts/run-docker.sh ./build-package.sh aapt -i

aapt, aapt2, aidl deb files will be in the output dir

also don't forget to install dependencies:

apt install fmt libc++ libexpat libpng libzopfli zlib

probably only for arm32 build:
also I should link this libraries statically or add them as dependencies but for now you also need:
apt install libprotobuf abseil-cpp

works on clean termux install on arm32 just with apt install PATH_TO_AAPT; apt install PATH_TO_AAPT2

_TAG_VERSION=13.0.0
_TAG_REVISION=6
_TAG_VERSION=15.0.0
_TAG_REVISION=23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be revision 36 which is the newest of this major version (or version 16.0.0 revision 2 which exists and is the newest overall)?

_TAG_VERSION=15.0.0
_TAG_REVISION=23
TERMUX_PKG_VERSION=${_TAG_VERSION}.${_TAG_REVISION}
TERMUX_PKG_REVISION=18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is proper for this line TERMUX_PKG_REVISION to be deleted because TERMUX_PKG_VERSION increased, is that correct? or is this package a special case (there are no other special cases as far as I know so if this package is one, I would also be interested to find out why)

termux_step_make() {
. $TERMUX_PKG_BUILDER_DIR/sources.sh

termux_setup_protobuf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is termux_setup_protobuf needed again here when it was already used during termux_step_pre_configure?


termux_setup_protobuf

export PATH=$TERMUX_PKG_HOSTBUILD_DIR/_prefix/bin:$PATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this line no longer necessary because there is no hostbuild-step in this package anymore, so this folder does not exist?


termux_setup_protobuf

export PATH=$TERMUX_PKG_HOSTBUILD_DIR/_prefix/bin:$PATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, a few lines above this line, there is a block

	# Certain packages are not safe to build on device because their
	# build.sh script deletes specific files in $TERMUX_PREFIX.
	if $TERMUX_ON_DEVICE_BUILD; then
		termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds."
	fi

This is outdated and this package is not unsafe for on-device build anymore. This is here because once, long ago, aapt used to use rm -rf $TERMUX_PREFIX/include/aosp during build.sh, but it doesn't anymore and things changed so that folder doesn't exist in any present-day Termux anymore.

TERMUX_PKG_MAINTAINER="@termux"
_TAG_VERSION=13.0.0
_TAG_REVISION=6
_TAG_VERSION=15.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an additional patch you will need in order to successfully build this PR after the update to NDK r28c.

--- a/base/tools/aapt/ResourceTable.h
+++ b/base/tools/aapt/ResourceTable.h
@@ -20,6 +20,8 @@
 class XMLNode;
 class ResourceTable;
 
+#include "XMLNode.h"
+
 enum {
     XML_COMPILE_STRIP_COMMENTS = 1<<0,
     XML_COMPILE_ASSIGN_ATTRIBUTE_IDS = 1<<1,

@robertkirkman
Copy link
Member

robertkirkman commented Aug 25, 2025

I have noticed that this package actually is safe for attempting on-device builds because the block which disables on-device building in aapt is outdated and no longer correct, and I have found that it is possible to produce and test them using this series of commands, however, unfortunately, the aapt2 that results from my on-device building has a bug that is not present in the cross-compiled version. I will explain all details of what I have observed so far for the purpose of documentation.

pkg upgrade
termux-setup-storage
pkg install git wget gradle
pkg remove aapt aapt2 # remove preexising installations - IMPORTANT
git clone -b aapt_15_23 https://github.com/birhburh/termux-packages.git termux-packages-aapt-15-src
git clone https://github.com/termux/termux-packages.git termux-packages-aapt-15-dest
rm -rf termux-packages-aapt-15-dest/packages/aapt
cp -r termux-packages-aapt-15-src/packages/aapt termux-packages-aapt-15-dest/packages/
cd termux-packages-aapt-15-dest
sed -i -e '/if $TERMUX_ON_DEVICE_BUILD/,+3d' packages/aapt/build.sh
export TERMUX_PKG_TMPDIR=$PREFIX/tmp TERMUX_JAVA_HOME=$PREFIX/lib/jvm/java-21-openjdk
scripts/setup-android-sdk.sh
scripts/setup-termux.sh
./build-package.sh -I -f aapt
cd output
apt reinstall ./*.deb
cd ../..
mkdir -p ~/.gradle
echo "android.aapt2FromMavenOverride=$PREFIX/bin/aapt2" > ~/.gradle/gradle.properties
git clone https://github.com/Appliberated/HelloWorldSelfAware.git
. termux-packages-aapt-15-dest/scripts/properties.sh 
echo "sdk.dir=$ANDROID_HOME" > HelloWorldSelfAware/local.properties
cd HelloWorldSelfAware
gradle assembleDebug

However, this error happens, indicating that on-device builds of aapt2 are malformed (this doesn't happen with cross-compiled builds of the aapt2 .deb file that are copied from the cross-compiler device to the Termux device and installed)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > AAPT2 bin Daemon #0: Unexpected error during link, attempting to stop daemon.
     This should not happen under normal circumstances, please file an issue if it does.

Unfortunately I do not know how to debug or fix that error but I wanted to post it here so that it is documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

7 participants