[APP] Zipalign binary and script - Optimize installed applications

Search This thread

senab

Senior Member
Apr 29, 2008
383
31
London, UK
www.senab.co.uk
Hey everyone,

Zip Align reduces the amount of RAM used during processing running for a major speed increase in running the apps: http://developer.android.com/guide/developing/tools/zipalign.html

I had been messing about with a script to pull apks off my phone, zipalign them and then push them back, but then I saw wesgarner's CM build with a binary and script for use on your phone. I don't really want to mess round with flashing a ROM just for that though, so I've ripped them out and uploaded them below. Another reason is I want to run this manually (with GScript) rather than on boot (as it does in wesgarner's ROM).

I take no credit for this, the binary and script were both taken from wesgarner's CM buiild.

To "install" this, just adb push the two files in the zip below onto your phone with:

Code:
adb shell mount -o remount,rw /system
adb push zipalign /system/bin
adb push zipalign_apks /system/sd/zipalign_apks.sh
adb shell chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
adb shell mount -o remount,ro /system

Then anytime you want to run the script just do:
Code:
adb shell sh /system/sd/zipalign_apks.sh
Or in terminal:
Code:
su
sh /system/sd/zipalign_apks.sh

Has been tested on CM 4.2.7.1 ;)
 

Attachments

  • zipalign.zip
    11.6 KB · Views: 9,142
Last edited:

LucidREM

Senior Member
Jan 18, 2009
1,571
5
Baltimore
www.lucidrem.us
ZipAlign

Hey everyone,



I had been messing about with a script to pull apks off my phone, zipalign them and then push them back, but then I saw wesgarner's CM build with a binary and script for use on your phone. I don't really want to mess round with flashing a ROM just for that though, so I've ripped them out and uploaded them below. Another reason is I want to run this manually (with GScript) rather than on boot (as it does in wesgarner's ROM).

I take no credit for this, the binary and script were both taken from wesgarner's CM buiild.

To "install" this, just adb push the two files in the zip below onto your phone with:

Code:
adb shell mount -o remount,rw /system
adb push zipalign /system/bin
adb push zipalign_apks.sh /system/sd
adb shell chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
adb shell mount -o remount,ro /system

Then anytime you want to run the script just do:
Code:
adb shell /system/sd/zipalign_apks.sh
Or in terminal:
Code:
su
sh /system/sd/zipalign_apks.sh

Has been tested on CM 4.2.7.1 ;)

i do not even know what zipalign does .. but i did add this to my script

# lucid -z

so .. what does it do exactly?
 

senab

Senior Member
Apr 29, 2008
383
31
London, UK
www.senab.co.uk
Last edited:

senab

Senior Member
Apr 29, 2008
383
31
London, UK
www.senab.co.uk
Sweet... Thanks...

I was surprised that more than half of the Apps I have were already ZipAligned...

Since the 1.6 SDK was released, the ADT does this automatically on APK export. Therefore any app which has been updated since ~September (and was developed using the ADT Eclipse plugin) will be zipalign'd. I was more surprised that 12 out of the 43 apps on my phone weren't aligned!
 

LucidREM

Senior Member
Jan 18, 2009
1,571
5
Baltimore
www.lucidrem.us

overground

Retired Senior Moderator / Inactive Recognized Dev
Thanks much for this!
Here is a simple gscript to install zipalign after a wipe or new build flash.
You must first create directory /sdcard/zipalign and place zipalign from the zip in the OP there. Path to the file should now be /sdcard/zipalign/zipalign.
Place this script in your gscript folder (after removing .txt from the name) and load it in gscript with su permissions.

I also find it easier to run the script in the zip from the OP in Gscript as well. Instead of placing it in /system/sd run this (assumes zipalign_apks.sh is at root of C:\)
Code:
adb remount
adb push C:\zipalign_apks.sh /sdcard/gscript/zipalign_apks.sh
Then just load it into Gsrcipt with su permissions as with the other script.

Easiest of all may just be to use the commands within Lucid's script. But, I'm comfortable with Gscript, and I can make it 2 clicks away.

EDIT: First execution, you may want to run the original way, because guess what? Gscript isn't zipaligned.:p But it worked fine just the same.
 

Attachments

  • install_zipalign.sh.txt
    143 bytes · Views: 818
Last edited:

g1DDriver

Senior Member
Nov 24, 2009
60
4
Google Pixel 6 Pro
Thanks. I didn't want to flash whole ROM to zipalign apps, so script was very handy.
Actually I've zipaligned only 2 apps, one of them was everybody loved Linda :eek:
 

wesgarner

Senior Member
May 10, 2007
825
63
Birmingham, AL
i do not even know what zipalign does .. but i did add this to my script

# lucid -z

so .. what does it do exactly?

I put a quick explanation of my script on my ROM page: here ya go (rough explanation)
Zip Align reduces the amount of RAM used during processing running for a major speed increase in dex-opt and running the apps, along with the RAM hack and a CC (or your userinit) boots speeds incredibly and better usability of apps (boot and system) in Android: http://developer.android.com/guide/d.../zipalign.html
Most developers have not used this yet (CM does ZipAlign his apps), but this does for the system apps provided from the now old Google Apps
 

MontAlbert

Senior Member
Jan 10, 2007
2,655
198
can someone make a script for windows or a bat file that can zipalign a batch of apks? I am not that ofay with line commands and when i create a new theme (which i often do), i then have to go and zipalign every single apk i have altered 1 at a time..... i do:

Code:
zipalign -f -v 4 E:\app\theapp.apk E:\app\theapp.apk.out
 

turboyo

Senior Member
Jun 23, 2009
591
2
Miami
Unzip the files to your SD Card, then:

Code:
su
mount -o remount,rw /system
cp /sdcard/zipalign /system/bin
cp /sdcard/zipalign_apks.sh /system/sd
chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
mount -o remount,ro /system

;)

This isnt working for me bc of the .sh after zipalign_apks .. do i rename the zipalign_apks to zipalign_apks.sh after unzipping?

edit:that worked :eek: THANKS!
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Hey everyone,

    Zip Align reduces the amount of RAM used during processing running for a major speed increase in running the apps: http://developer.android.com/guide/developing/tools/zipalign.html

    I had been messing about with a script to pull apks off my phone, zipalign them and then push them back, but then I saw wesgarner's CM build with a binary and script for use on your phone. I don't really want to mess round with flashing a ROM just for that though, so I've ripped them out and uploaded them below. Another reason is I want to run this manually (with GScript) rather than on boot (as it does in wesgarner's ROM).

    I take no credit for this, the binary and script were both taken from wesgarner's CM buiild.

    To "install" this, just adb push the two files in the zip below onto your phone with:

    Code:
    adb shell mount -o remount,rw /system
    adb push zipalign /system/bin
    adb push zipalign_apks /system/sd/zipalign_apks.sh
    adb shell chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
    adb shell mount -o remount,ro /system

    Then anytime you want to run the script just do:
    Code:
    adb shell sh /system/sd/zipalign_apks.sh
    Or in terminal:
    Code:
    su
    sh /system/sd/zipalign_apks.sh

    Has been tested on CM 4.2.7.1 ;)