fix: accept empty resources.arsc #2998
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Apktool treats APKs with stub resources.arsc like criminals:
But in fact, those APKs are valid and very common among overlay APKs, but here's a non-overlay example as well:
https://drive.google.com/file/d/1seAnndB9cH6_qo04FC7_1JPW5CVXLMnt/view
This change creates a "fake ResPackage", exactly as done in decodeManifest, if resources.arsc was loaded but contains 0 packages.
The output is valid and recompilation already produces an identical 40 bytes stub resources.arsc without any additional changes needed.
P.S. also fixed a few missing spaces for cleanliness.