Sample Header Ad - 728x90

Strip /lib from installed apk

4 votes
1 answer
706 views
Most apks have a /lib dir inside with .so files that can be several megabytes. Some even come loaded with libs for different architectures (arm, mips, x86). Libs for relevant arch are copied in /data/app-lib/[package name] at install time, so they take double the space. I tried to strip the apk from the /lib folder, rewrite, zipalign and put back to install location /data/app or /system/app or /system/priv-appto reclaim some space. Tried with Chrome v78, it went from 45 mb apk to 15 mb... Other apps too. Everything seems to work. Anyone thinks it's a bad idea? IMO the very Android system should perform this operation by default at install time... ***edit 13 Nov*** I wrote a script to automate the strip operation, just have to copy the apk to strip in a dir where this script resides, along with zip and zipalign binaries. #!/system/bin/sh for filename in find . -name '*.apk' do ./zip -d $filename "lib/*" ./zipalign -fv 4 $filename $filename.new|tail mv $filename.new $filename chmod 644 $filename done; On my device I can swap original with stripped apks on the fly and they (usually) run fine without rebooting, even system apps.
Asked by Ju Tutt (524 rep)
Nov 12, 2019, 01:27 PM
Last activity: Nov 13, 2019, 10:07 AM