Apktool
Apktool copied to clipboard
fix: rename resources when package name is changed
trafficstars
Why
trying to fix the issue when renameManifestPackage is specified, package name in resources.arsc isn't updated. i tested with --use-aapt2, which is also the implicit default in the latest version.
How
aapt2 has an additional --rename-resources-package option and we should use it in renameManifestPackage case.
Test Plan
manual tests
# use a random sample apk to test
$ apktool d brut.apktool/apktool-lib/src/test/resources/issue2836/issue2836.apk -o testapp
# add renameManifestPackage
$ yq -i '.packageInfo.renameManifestPackage = "com.example.aapt2"' testapp/apktool.yml
# tested with official apktool v2.11.1
$ apktool b -o testapp.apk testapp
$ aapt2 dump resources testapp.apk | grep 'Package name='
Package name=com.ibotpeaches.issue2836 id=7f
# tested with my local build with the patch
$ java -jar ./brut.apktool/apktool-cli/build/libs/apktool-v*.jar b -o testapp.apk testapp
$ aapt2 dump resources testapp.apk | grep 'Package name='
Package name=com.example.aapt2 id=7f