Save application memory

Search This thread

arpruss

Senior Member
Jul 3, 2010
909
434
pruss.mobi
Here's a way to save memory on apps that have large native libraries but haven't been moved to SD (you can also do this with apps that have been moved to SD, but it's a bit more complicated).

Background: Many apps have large native libraries, several megabytes in size. In fact, in some apps, the apk is mainly native libraries. The needed native libraries get transfered to a /data/data/package.name/lib when the apk is installed, but they are also kept in the apk. If we could delete them from the apk, we would save memory. The only tricky thing is that if we just delete the libraries from the apk, next time the system reboots, they'll be deleted from /data/data/package.name/lib . So you just need to set /data/data/package.name/lib/* to read-only.

How to do it: You need a rooted device and to be comfortable with doing things from the commandline. I will assume an rw root (I use chulri's). If you have read-only root, you need to install stuff in a different directory and edit the scripts.

Download and extract zip.zip. Transfer the files zip and striplib.sh to /bin on your device, for instance by doing on your PC:
Code:
adb push zip /tmp
adb push striplib.sh
adb shell
su
chmod 755 /tmp/striplib.sh /tmp/zip 
mv /tmp/striplib.sh /tmp/zip /bin
This installs striplib.sh and a zip archiver.

Now, you'll want to determine which applications have large libraries. To do that, continue in the shell as follows:
Code:
cd /data/data
du */lib
You will thereby find out which apps have large libraries.

You can now strip out the libraries from the apk by running:
Code:
striplib.sh package.name
where "package.name" is the java package name of the apk you want to strip. When you did the "du */lib", you will have got a list of the package names. For instance, for the APV PDF Viewer:
Code:
striplib.sh cx.hell.android.pdfview

Repeat for other apps. But I recommend rebooting the device after doing the first app to make sure the app is still working, as a compatibility test.

Note: I am not a lawyer. striplib.sh deletes the libraries from the apk file. I do not know if this legally counts as a forbidden modification of the application in the sense of the Android Market or Amazon Appstore Terms of Service (one could see it as just an optimization of the installation process, perhaps?). But to be on the safe side legally, I've only done this myself with apps that didn't come from the Market or Appstore, like APV.