Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,814,393 Members 53,568 Now Online
XDA Developers Android and Mobile Development Forum

[APP] Zipalign binary and script - Optimize installed applications

Tip us?
 
senab
Old
(Last edited by senab; 5th December 2009 at 01:36 PM.)
#1  
senab's Avatar
Senior Member - OP
Thanks Meter 32
Posts: 382
Join Date: Apr 2008
Location: London, UK

 
DONATE TO ME
Default [APP] Zipalign binary and script - Optimize installed applications

Hey everyone,

Quote:
Originally Posted by wesgarner View Post
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/d.../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
Attached Files
File Type: zip zipalign.zip - [Click for QR Code] (11.6 KB, 4877 views)
Galaxy Nexus. Nexus 7. iPhone 4S. Motorola Xoom 4G. HTC Desire. Samsung Galaxy SII. HTC Wildfire.

Apps: Friendcaster for Facebook - photup
Apps worked on: Samsung Hope Relay - Sky Go for Android - rara
Old Projects: brightbuyr - Custom MMS User Agent Patch - CM Updater - HeroLED
Twitter



The Following 3 Users Say Thank You to senab For This Useful Post: [ Click to Expand ]
 
LucidREM
Old
#2  
LucidREM's Avatar
Senior Member
Thanks Meter 5
Posts: 1,569
Join Date: Jan 2009
Location: Baltimore
Exclamation ZipAlign

Quote:
Originally Posted by senab View Post
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?
"I fear explanations explanatory of things explained."
There are 10 types of people in this world: one who understands binary and one who does not.
__________________
HTC Dream (T-Mobile) / HTC Sapphire (T-Mobile) | TheOfficial DONUT TMO US/EU & AOSP - v2.6.3
CaNNoN202v2.1_EPE54 | Recovery: RAv1.7.0 | Radio: 2.22.23.02 | 8GB MicroSD
Get ROOT'ed - CR*/DR* | Lucid's "swiss army knife"
 
Vermithrax
Old
#3  
Vermithrax's Avatar
Senior Member
Thanks Meter 2
Posts: 108
Join Date: Feb 2009
Location: Mobile, AL
Sweet... Thanks...

I was surprised that more than half of the Apps I have were already ZipAligned...
T-Mobile GSIII & Nook Color


Tried Dropbox yet??? Use the following
link to sign-up and we both get an extra
250MB!!
Dropbox Referral Link
 
senab
Old
(Last edited by senab; 4th December 2009 at 08:16 PM.)
#4  
senab's Avatar
Senior Member - OP
Thanks Meter 32
Posts: 382
Join Date: Apr 2008
Location: London, UK

 
DONATE TO ME
Quote:
Originally Posted by LucidREM View Post
i do not even know what zipalign does .. but i did add this to my script

# lucid -z

so .. what does it do exactly?
APKs (as you probably already know) are just zip files. zipalign simply aligns the APK on 4-byte boundaries which Android is more efficient wrt memory access.

You can read more from Jean-Baptiste Queru at http://android-developers.blogspot.c...imization.html
Galaxy Nexus. Nexus 7. iPhone 4S. Motorola Xoom 4G. HTC Desire. Samsung Galaxy SII. HTC Wildfire.

Apps: Friendcaster for Facebook - photup
Apps worked on: Samsung Hope Relay - Sky Go for Android - rara
Old Projects: brightbuyr - Custom MMS User Agent Patch - CM Updater - HeroLED
Twitter



 
senab
Old
#5  
senab's Avatar
Senior Member - OP
Thanks Meter 32
Posts: 382
Join Date: Apr 2008
Location: London, UK

 
DONATE TO ME
Quote:
Originally Posted by Vermithrax View Post
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!
Galaxy Nexus. Nexus 7. iPhone 4S. Motorola Xoom 4G. HTC Desire. Samsung Galaxy SII. HTC Wildfire.

Apps: Friendcaster for Facebook - photup
Apps worked on: Samsung Hope Relay - Sky Go for Android - rara
Old Projects: brightbuyr - Custom MMS User Agent Patch - CM Updater - HeroLED
Twitter



 
LucidREM
Old
#6  
LucidREM's Avatar
Senior Member
Thanks Meter 5
Posts: 1,569
Join Date: Jan 2009
Location: Baltimore
Arrow ZipAlign

Quote:
Originally Posted by senab View Post
APKs (as you probably already know) are just zip files. zipalign simply aligns the APK on 4-byte boundaries which Android is more much efficient wrt memory access.

You can read more from Jean-Baptiste Queru at http://android-developers.blogspot.c...imization.html
that's awesome .. thanks for the link .. i hadn't read about that
"I fear explanations explanatory of things explained."
There are 10 types of people in this world: one who understands binary and one who does not.
__________________
HTC Dream (T-Mobile) / HTC Sapphire (T-Mobile) | TheOfficial DONUT TMO US/EU & AOSP - v2.6.3
CaNNoN202v2.1_EPE54 | Recovery: RAv1.7.0 | Radio: 2.22.23.02 | 8GB MicroSD
Get ROOT'ed - CR*/DR* | Lucid's "swiss army knife"
 
overground
Old
(Last edited by overground; 4th December 2009 at 10:24 PM.)
#7  
overground's Avatar
Moderator & Developer Committee / Recognized Developer - xxxda-developers Founder
Thanks Meter 1,204
Posts: 5,286
Join Date: Apr 2009
Location: Oxnard, CA Likes: Los Angeles Lakers Dislikes: Heavy petting zoos
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. But it worked fine just the same.
Attached Files
File Type: txt install_zipalign.sh.txt - [Click for QR Code] (143 Bytes, 442 views)
 
T-mobile SDA, T-mobile G1 (bronze) Rooted, Nexus One Rooted 4.0.4, T-mobile G2x Rooted, Viewsonic G-tab 10.1", HTC OneX (SOLD), Kindle Fire Rooted, T-mobile SGS3 rooted, Note 10.1 rooted / GDE=360s of fun!! / pinkventure.com
Quote:
Originally Posted by dumfuq View Post
That is correct. Or you cold use the escape sequence instead of quotes.
Code:
sh /system/sd/bart.sh Double\ post -d -u -m -f -u -q knockeduphooker9.1.1Full10-26-09
Buy me some meds
 
deadite66
Old
#8  
deadite66's Avatar
Senior Member
Thanks Meter 8
Posts: 186
Join Date: Oct 2008
worked great thanks.
 
g1DDriver
Old
#9  
g1DDriver's Avatar
Member
Thanks Meter 4
Posts: 56
Join Date: Nov 2009
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
 
garz
Old
#10  
Senior Member
Thanks Meter 31
Posts: 418
Join Date: Jan 2008
Location: Brooklyn, NY
so anyone wanna bless me with a terminal code to install the script?

Tags
1.21 gigawatts!
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA Xposed Tuesday: How to Shut Up Your Phone – XDA Developer TV

So many different applications want to send us notifications that … more

Add Some Power to First Generation Snapdragon CPUs

Some older devices still remain very popular. Phones like theHTC Desire, Sony Ericsson … more

Android M Mentions Spotted in Android Code Review

While we are still waiting for Android L to be officially released, the first mentions of … more

Create a Simple Custom Launcher from Scratch

When you are starting your journey intoany sort of development, it’s never easy at the … more