Igor Eisberg 4de92a23ae
refactor: ApkDecoder & ApkBuilder overhaul (#3699)
* refactor: ApkDecoder & ApkBuilder overhaul

A major rewrite of ApkDecoder and ApkBuilder classes to make them managable.
Removed many instances of redundancy and improved syntaxed and indentation.

Modifying the stock Apktool source to our needs have become too difficult,
so I'm pushing the general (not specific to our needs) changes upstream.

I'd change a lot more, but I wanted to make sure all tests pass as expected,
despite some of them being wierd, outdated or unnecessary.

This also fixes certain files in META-INF being lost during recompile
when the -c/--copy-original option isn't used.

This has been tweaked and tested for several days and I vouch for its stablity.

* style: fix more redundancy

* style: fix more redundancy

* tweak: consistent case-sensitivity for cmd and options

* refactor: tracking unknownFiles via apkInfo is redundant

1) We take advantage of the fact that doNotCompress already tracks uncompressed files,
   including those separated into "unknown".
   With this change the "unknownFiles" is simply ignored, so it's backward-compatible
   with existing decoded APK dirs.
   Tweaked a few tests to match the removal of "unknownFiles".

2) Passing doNotCompress to AAPT is redundant, Apktool extracts the temp APK packed by
   AAPT to build/apk and then repackages it anyway, so it serves no purpose.

* refactor: fix minSdkVersion from baksmali + clean up more redundancy

* Regression: minSdkVersion inferred from baksmali was not stored properly.

* The arsc extension can be generalized for simplicity as seen in AOSP source.
https://cs.android.com/android/platform/superproject/main/+/main:external/deqp/scripts/android/build_apk.py;l=644?q=apk%20pack&ss=android%2Fplatform%2Fsuperproject%2Fmain:external%2F
  Note:
    NO_COMPRESS_EXT_PATTERN only collapses paths to a common extension.
    It does NOT force these extensions to be always uncompressed.
    doNotCompress is the one determining files/extensions that should be uncompressed.
  (no funcionality was changed)

* resourcesAreCompressed in apkInfo is redundant. It was only used in invokeAapt,
  but not ApkBuilder. Its value is also never set by Apktool, only read.
  Like with doNotCompress, passing any kind of compression rules to AAPT is pointless,
  since we don't use the temp APK packed by AAPT directly - it's extracted and repacked
  by ApkBuilder, where doNotCompress already determines whether resources.arsc should
  or should not be compressed in the final APK.
  (no funcionality was changed)

* style: optional args come after required args

* style: optional args come after required args

* style: sdkInfo as a normal field for consistency

* style: some formatting tweaks
2024-10-03 06:52:59 -04:00
2021-08-27 01:20:06 +08:00
2021-03-07 15:03:11 -05:00
2023-10-08 14:59:26 -04:00
2024-08-01 08:12:29 -04:00
2019-07-14 08:09:21 -04:00

Apktool

This is the repository for Apktool. The website is on the Apktool docs branch.

CI Software License

Apktool is a tool for reverse engineering third-party, closed, binary, Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes it possible to debug smali code step-by-step. It also makes working with apps easier thanks to project-like file structure and automation of some repetitive tasks such as building apk, etc.

Apktool is NOT intended for piracy and other non-legal uses. It could be used for localizing and adding features, adding support for custom platforms, and other GOOD purposes. Just try to be fair with the authors of an app, that you use and probably like.

Support

Security Vulnerabilities

If you discover a security vulnerability within Apktool, please send an e-mail to Connor Tumbleson at connor.tumbleson(at)gmail.com. All security vulnerabilities will be promptly addressed.

Sponsors

Special thanks goes to the following sponsors:

Sourcetoad

Sourcetoad is an award-winning software and app development firm committed to the co-creation of technology solutions that solve complex business problems, delight users, and help our clients achieve their goals.

Emerge Tools

Emerge Tools is a suite of revolutionary products designed to supercharge mobile apps and the teams that build them.

Description
A tool for reverse engineering Android apk files
Readme 306 MiB
Languages
Java 98.6%
Shell 0.7%
Smali 0.5%
Batchfile 0.2%