Skip to content

refactor: migrate tests to aapt2 + related fixes #3865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

IgorEisberg
Copy link
Contributor

All tests have been migrated to aapt2, no tests left for aapt1, as we phase out support.

Fixed shared library support using a custom option -l or -lib, that can be specified many times for multiple libs. On decoding, the dynamic_ref_table is used to determine which shared libraries were used, and when done they are stored in ascending order in apktool.yml as a usesLibrary list. The order within usesLibrary determines the package IDs that will be dynamically assigned to shared resources on recompile. Works perfectly with aapt2, doesn't seem to work with aapt1 since it's garbage and never worked properly.
SharedLibraryTest was updated accordingly.

isFrameworkApk and sharedLibrary flags are obsolete. We decide aapt options to use by package ID.

values-godzilla dir omitted for now, currently aapt2 doesn't support it properly (needs more binary patching).

drawableXhdpiTest commented out for now until we decide what to do with those old Samsung and HTC 9patch drawables. aapt2 stores them with ".9" or ".r" appended to resource name, and the decoded files are named ".9.9.qmg" or ".r.r.9.png".

Some variable name tweaks for consistency.

All tests have been migrated to aapt2, no tests left for aapt1,
as we phase out support.

Fixed shared library support using a custom option '-l' or '-lib',
that can be specified many times for multiple libs.
On decoding, the dynamic_ref_table is used to determine which
shared libraries were used, and when done they are stored in
ascending order in apktool.yml as a usesLibrary list.
The order within usesLibrary determines the package IDs that will
be dynamically assigned to shared resources on recompile.
Works perfectly with aapt2, doesn't seem to work with aapt1
since it's garbage and never worked properly.
SharedLibraryTest was updated accordingly.

"isFrameworkApk" and "sharedLibrary" flags are obsolete.
We decide aapt options to use by package ID.

values-godzilla dir omitted for now, currently aapt2 doesn't
support it properly (needs more binary patching).

drawableXhdpiTest commented out for now until we decide what
to do with those old Samsung and HTC 9patch drawables.
aapt2 stores them with ".9" or ".r" appended to resource name,
and the decoded files are named ".9.9.qmg" or ".r.r.9.png".

Some variable name tweaks for consistency.
@IgorEisberg
Copy link
Contributor Author

IgorEisberg commented May 5, 2025

Shared libraries are dynamic so must be provided in decode/build time.
Example of usage:

java -jar bin/apktool.jar d -b -f -p framework -l com.google.android.test.shared_library:shared/shared_library.apk -l com.google.android.test.shared_library2:shared/shared_library2.apk test.apk -o test
cd test
java -jar ../bin/apktool.jar b -f -p ../framework -l com.google.android.test.shared_library:../shared/shared_library.apk -l com.google.android.test.shared_library2:../shared/shared_library2.apk

I need some rest now. -___-''

@iBotPeaches
Copy link
Owner

damn nice work

@IgorEisberg
Copy link
Contributor Author

By the way, this:

<item name="@string/issue_477">?android:dividerVertical</item>

and:

Are not a thing in aapt2 (I mean the string references for name), so omitted.

@IgorEisberg
Copy link
Contributor Author

I'm done with the tests. If you need help with removing aapt1 (and related "hacks" for it in the code) let me know.
Already did it for my private build long ago, after all.

@iBotPeaches
Copy link
Owner

iBotPeaches commented May 5, 2025

Are you wanting this branch to start the v3 branch? Or do you feel since none of the removals take place it should go out into wild under 2.x for a bit?

@IgorEisberg
Copy link
Contributor Author

Are you wanting this branch to start the v3 branch? Or do you feel since none of the removals take place it should go out into wild under 2.x for a bit?

It should be fine under 2.x as well, but it's up to you. Getting rid of aapt1 code is easy job in comparison to this.

@iBotPeaches
Copy link
Owner

Okay so my plan then is:

  • Merge this, probably weekend
  • Await Android 16 GA, early June?
  • Cut 2.12.0, hopefully 1-2 days after that
  • Turn mainline into 3.0.0-SNAPSHOT and remove aapt1

@iBotPeaches
Copy link
Owner

Added a draft PR for docs for the new param - iBotPeaches/apktool.org#16

@IgorEisberg
Copy link
Contributor Author

Okay so my plan then is:

  • Merge this, probably weekend
  • Await Android 16 GA, early June?
  • Cut 2.12.0, hopefully 1-2 days after that
  • Turn mainline into 3.0.0-SNAPSHOT and remove aapt1

Fair enough, hopefully nobody touches anything that would conflict with this change.

@iBotPeaches
Copy link
Owner

I'll keep things unmerged till this and I wasn't sure if you were done with commits so felt weekend was safe.

@IgorEisberg
Copy link
Contributor Author

I'll keep things unmerged till this and I wasn't sure if you were done with commits so felt weekend was safe.

Yeah, I'm done with this PR. Not touching more than that until we're ready to cut aapt1 out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants