Related
Update 9/28: Now contains the SDK 1.6 zipalign binary and routine to align each APK after optimization. This results in slightly larger file sizes but a smaller RAM footprint and faster performance. For more information about zipalign, see http://android-developers.blogspot.com/2009/09/zipalign-easy-optimization.html
Update 9/16: new zip defaults to mx5 zip compression, creates "original" and "optimized" folder for apks.
This is a very simple batch file that makes use of command line 7-zip and a special build of optipng (supporting recursive optimizing) to reduce the size of the PNGs in your APKs. This would reduce the overall memory footprint of your apps, and allow you to fit more on the phone's puny internal memory.
As for how much this helps, here's a test run on the latest JACxHeroSki:
Size of uncompressed folder of data/app_s before optimization: 57.3 MB
Size of uncompressed folder of data/app_s after optimization: 43.1 MB
To use it, simply copy all the APKs you want optimized into the batch files' directory and run "apkopt_all.bat" This will take a while but it's all automated! This will then create two folders, optimized and original.
To make the optimization process faster, reduce the "-o99" parameter in apkopt.bat - however, this will result in larger PNGs so best to leave it at o99 and wait. You can also tweak the compression level of the ZIP itself - I left it at "normal" (-mx5) because higher compression levels have reported problems with some APKs.
Once done, the APKs will not be signed but that should not be an issue if you're bundling the APK with a ROM or pushing it through adb.
Optimization has no negative effects, it just makes the PNGs smaller.
Windows only for now - the variant of optipng that this depends on only has a Windows binary available.
It definitely makes a difference!
This distribution includes 7-zip and a variant of optipng called roptipng. Sources can be found:
http://www.7-zip.org/
http://code.google.com/p/roptipng/
I apologize for my noobish Windows command line knowledge. Many devs (like Cyanogen) already seems to have been doing this long ago! His builds are so optimized you can't optimize them more. Any size difference will be due to different compression methods/levels on the ZIP.
sweet, will you do it so I can test it on jacheroskiv2.1 and 2.2? i have a mac w/ ubuntu. no windows!
Is this even necessary when pretty much every ROM uses app2sd?
And wouldn't zipping the png slow things down because the OS now needs to unzip before running?
dwang said:
Is this even necessary when pretty much every ROM uses app2sd?
And wouldn't zipping the png slow things down because the OS now needs to unzip before running?
Click to expand...
Click to collapse
not everyone needs to have hundreds of apps and therefore no need to run apps2sd.
ccyrowski said:
sweet, will you do it so I can test it on jacheroskiv2.1 and 2.2? i have a mac w/ ubuntu. no windows!
Click to expand...
Click to collapse
I'm in the process of making/uploading a pack of APKs of javheroski 2.1.
dwang said:
Is this even necessary when pretty much every ROM uses app2sd?
And wouldn't zipping the png slow things down because the OS now needs to unzip before running?
Click to expand...
Click to collapse
No, this isn't actually zipping the PNGs themselves - the only purpose 7-zip serves is to unpack and repack the APKs.
coolbho3000 said:
I'm in the process of making/uploading a pack of APKs of javheroski 2.1.
No, this isn't actually zipping the PNGs themselves - the only purpose 7-zip serves is to unpack and repack the APKs.
Click to expand...
Click to collapse
Oh cool... I can see the usefulness of having smaller pngs..
I have a similar script that I used for my build, but i used the regular optipng at -o7 for all files. This should help me cram more stuff on my rom, thanks bunches. I have a question, though, I've yet to test this, but is there any adverse effect from running 9-patched pngs through optipng? They're encoded with extra instructions for stretching and padding. In my build, I only ran regular pngs, but if I were able to run the whole thing... I have to try this but I'm at work... Oh, wait, I'm the boss!, I'll try this later today.
---edit---
Oh, cool, I guess I didn't read right. I was trying to modify the thing so that it would recursively optimize extracted pngs in windows folders, but I read the bats and it actually opens up the zips and does all this itself, great! I should have read the post more closely.
dwang said:
Is this even necessary when pretty much every ROM uses app2sd?
And wouldn't zipping the png slow things down because the OS now needs to unzip before running?
Click to expand...
Click to collapse
my builds run pretty quick... I was doing this manually app by app. Check the new version I release and ask again cuz I only got half through them.
uhm i cant seen to get this to work. download your zip and extracted it to a folder. four files in it. placed all my apks into this same folder. ran the batch file but it just opened up and closed and outputted a 1kb file called "and"
NguyenHuu said:
uhm i cant seen to get this to work. download your zip and extracted it to a folder. four files in it. placed all my apks into this same folder. ran the batch file but it just opened up and closed and outputted a 1kb file called "and"
Click to expand...
Click to collapse
Need to be on your c drive or local.
drieves1 said:
Need to be on your c drive or local.
Click to expand...
Click to collapse
ok got it thanks! it was on my secondary drive not C drive. i tried it on cyanogen's system apps and it went from 14.2MB to 13.7MB, not a huge improvement but an improvement nonetheless. this app has a lot of potential for hero roms that really need those extra MBs haha.
if only the batch file can be edited to automatically create duplicate apk instead of overwriting just in case forget to backup. happens sometimes haha. maybe signing can be added to the batch script as well for market apps that need to be resigned since you cant just push them through like you can with system apps that are apart of the rom, they need to be installed.
dont try this on your framework though >.<. I did and it wouldn't boot, seems compression was too aggressive (something about 2XXXXXX to 1XXXXX something, dont remember what it was, but I think bringing o-49 should probably fix it for framework)
UNCOMPRESS_DATA_MAX (XXXXXXX vs 1048576). Causes errors on APKs that are over compressed. Any idea what setting it could be to keep it under that threshold?
hrmm.... I saw what's going on.... For some reason, the script is also processing resources.arsc. This file has to be left alone or it causes problems. I used the script to optimize all pngs, then i extracted all apks, and then i used the optimized pngs and put them back on the regular apks and it worked perfectly, though the gain is much, much more modest, about ~300KB coming from my previous -o7 optimization, and I guess I can attribute that to the 9 patch pngs I hadn't processed the first time around. Am I wrong that resources.arsc should be left untouched? a 10 MB gain is just what I needed to make all of hero fit in death spl's /system (and light hero on a regular spl).
ok, i see, the problem is the re-compression of the apk. I think it's not using the same zip format, so when dalvik tries to expand it causes a problem. roptipng should still save me A LOT of time though...
I'm not home now but try making the -mx9 parameter for 7-zip in apkopt.bat lower as well.
cool stuff, thanks man!
First, thanks for doing this. I have a suggestion. I think you should create an "original" folder and an "optimized" folder (or whatever names you like). So that you can drop the files into the original folder rather than copying them into the same directory. It would just be cleaner that way. Also, you could keep the orginal files in that folder and put the new ones into the optimized folder so people don't need to back them up. They would have both the original and optimized files when the process is finished.
Uploaded a new one with that. Thanks
Have you investigated into why some apks don't work after being compressed? or am I the only one having problems? Some apps compress at best compression and still work, but other apps have to be compressed less in order to work. I tried compressing the whole batch, and then trying to see which ones failed and then try compressing again with a lower setting, etc etc, but it's hard to do for services and non-launcher apps because you don't notice they don't work until you need them. I've seen other people use these scripts and produce working roms, so it might be something different with my setup (win7 64)
Long time lurker here. I've been following this forum for some time and was wondering if anyone has found and successfully edited the host file so that ads no longer load, thereby saving much bandwidth and getting snappier-loading web pages. It's been done on the Palm Pre and iPhone, and I've tried to find the host file on the Hero, but no luck yet.
lostnfound53 said:
Long time lurker here. I've been following this forum for some time and was wondering if anyone has found and successfully edited the host file so that ads no longer load, thereby saving much bandwidth and getting snappier-loading web pages. It's been done on the Palm Pre and iPhone, and I've tried to find the host file on the Hero, but no luck yet.
Click to expand...
Click to collapse
I believe there is an app somewhere on the marketplace that does this for you. But either way, Android is a linux system like any other (albeit highly stupified by Google) so the hosts file is /system/etc/hosts.
chuckhriczko said:
I believe there is an app somewhere on the marketplace that does this for you. But either way, Android is a linux system like any other (albeit highly stupified by Google) so the hosts file is /system/etc/hosts.
Click to expand...
Click to collapse
Ah yes, I did find another thread in the (G1) Dream forum with steps on how to do this. Thanks for the reply.
Ad-less browsing.
All you have to do is put it in the /system/etc/ folder.
ajones7279 said:
Ad-less browsing.
All you have to do is put it in the /system/etc/ folder.
Click to expand...
Click to collapse
You are the man (or woman?)! Thanks!
Man.
ajones7279 said:
Ad-less browsing.
All you have to do is put it in the /system/etc/ folder.
Click to expand...
Click to collapse
I realize that this is a totally nub question but I can't seem to figure it out. How do I copy this host file from my Windows computer to the /system/etc/ folder on the Hero? It'd be awesome to be able to browse the phone's filesystem from Windows but, alas, no such luck.
Hey guys,
I am in need of your help, obviously .
I have downloaded an app called FeebeRingtones. It works pretty good so far, apart from an annoying point.
You get the option to download some songs from it, which are apparently saved in the /sdcard/FeebeRings/mp3 folder. This annoys me because it essentially makes those downloaded mp3 ringtones playable from my media player.
What i want to do is edit the apk and make it save in /sdcard/media/audio/ringtones folder. I've opened up the apk, and got to a file named file_save.xml. Thing is when i open that file up its content shows up as gibberish. I tried opening it with an xml editor (Open XML Editor 1.6) but still no luck at all.
Can anyone point me at the right direction, as to what program to use and edit it?
I am attaching the file_save.xml in case anyone wants to have a look and help me out.
Thank you very much for your time.
Hi guys!
This is a quick tool I jotted together for myself in the past couple days and found it very useful. So I decided to clean it up and share it. Hope you will like it! Do comment and ask!
APK Batch Rename Tool
* for Windows and Linux for now.
APK Batch Rename Tool recursively crawls input folder and all of its subfolders looking for Android Package files (.apk's). It reads Label and Version info from apk's found and creates a copy for each apk under the output folder but using the Label and Version info acquired.
For example a com.example.hw.apk will make Hello World! 1.21.apk provided that the label inside the package was set to Hello World! and version is 1.21.
The old and the new apk files are 100% the same in terms of content and are unchanged. Only the new copies are given new filenames. Input files are left completely intact.
Why?
Have you ever wondered what are your 1500+ apk files with wierd names nested to different wierd folders on your harddrive? Have you ever wanted to find an app but you were unable to because it had some undescriptive javaish name that made no sense reflected no version and your apps were swept across a hundred junk folders anyway? Then APK Batch Rename is the tool for you! And me!
APK Batch Rename will set a human readable name for all your Android apps, and drop such a copy into a folder. You will finally be able to browse them, sort them alphabetically and be able to pick from versions available.
How?
1. Copy all your apk files (or folders with apk files in them) into the input folder. You may copy folders of any depth. APK Batch Rename Tool will recurse all subfolders of the input folder anyway.
2. Hit or click ApkBatchRename.bat . (For Linux users it's: apkbatchrename, or on a terminal enter: ./apkbatchrename ) Wait until it finishes the job.
3. Find your freshly named files in the output folder.
Simple as that!
Have fun! & Comment!
phsorx
great work, just like reading mp3 tag then rename to "song - artist.mp3"
thanks!
Cool. I use to do it manually. Time saver app.
Thanks.
This is awesome! Thank you very much, situation you described in first post is just like mine, I find your tool very useful!
Folks,
Let me join you crediting phsorx's job, that app is just great!
Thanks and congrats!
Very cool, Works well. Always wanted to do this but was too lazy to try aapt.
I just checked:
aapt said:
badging Print the label and icon for the app declared in APK.
Click to expand...
Click to collapse
Code:
> aapt d badging Talk.apk
[B]package: name='com.google.android.talk' [/B]versionCode='130' [B]versionName[/B]='1.3'
sdkVersion:'8'
targetSdkVersion:'8'
uses-permission: **truncated***
application: [B]label='Talk'[/B] icon='res/drawable-hdpi/ic_launcher_google_talk.png'
uses-feature:'android.hardware.touchscreen'
main
other-activities
search
other-receivers
supports-screens: 'small' 'normal' 'large'
locales: '--_--' 'es' 'es_US'
densities: '160' '240'
I'll definitely use your script but with a small change to show the package name as well as its valuable for when you need to uninstall the package.
i.e label_packagename(version).apk -> Talk_com.google.android.talk(1.3).apk
Attached a slightly modified batch file and screenshot
For single file one-off renames (right-click->open with->rename single) you can use the script here.
De jo! Honfitars. Hajra Magyarok!
Customizable naming planned in future version
britoso said:
Very cool, Works well. Always wanted to do this but was too lazy to try appt.
i.e label_packagename(version).apk -> Talk_com.google.android.talk(1.3).apk
Click to expand...
Click to collapse
Hi Britoso,
Yeah! That's a neat way to do it too!
Eventually I want to make naming and spacing fully customizable! Including what attributes to pick (name, label, versionName) to constitute the filename, and what separators (_,-,(,),space) should go where.
In the howto.txt I have a little road-map for the project. Will add customizable naming too.
Will keep you guys posted.
EOF
phsorx
Ps: Anyone who has another naming suggestion drop a post! I'd be interested.
great job...bravo..
thanks
Very nice tool, thanks for sharing this .
Using it with britoso's edited script.
Edit: I would appreciate it if a log of the conversion would be saved in a \logs\ subfolder, so I can check which files were not converted properly and see if I have to do those manually.
Handy ! Thanks...
deleted
For one-off renames you can use the below batch file.
1) create the below batch file in the same folder as apkrename.bat (its attached too)
Name: rename-single.bat (change this if you want)
content:
Code:
cd "C:\change_me\ApkRename\"
apkrename.bat %1 %~dp1
Change the path(change_me) as needed.
2)Associate it with apks by right clicking on the apk and choosing "choose default program", browse and select the batch file "rename-single.bat".
Uncheck "make this the default operation"
Screenshot and batch file attached. Enjoy.
update:
-12/8 uploaded a new version that fixed a bug involving long path names with spaces.
Also added a check for success and then delete the original apk. (backup your apks just in case).
Remember to set the path to the ApkRename folder in rename_single.bat once before using it.
Really gd job )
APK Batch Rename Tool for Linux is on the way
luvgirl12345 said:
would like a linux version...
Click to expand...
Click to collapse
Hi luvgirl12345,
The Linux port is on the way & will be posted here soon!
Actually, the Windows release is running on win32 ports of a few common Linux tools. And that's so, because I am lazy. Having Linux's much better support for shell scripting plus the same tool set always at hand, porting is a breeze.
Ciao,
phsorx
Sounds very useful, thank you!
Looks nice for massive apk renaming.
Found a similar tool called APKInfo some month ago which i am using for single apk files for a while now.
But finally something for batch renaming.
Thanks
your the man!, works like a charm. Thanks!
Any plans for making an Android version of this to run on our devices?
Future plans for an on-phone version of the APK Rename Tool
del4 said:
Any plans for making an Android version of this to run on our devices?
Click to expand...
Click to collapse
Yes! Certainly. Its in the plans.
But firstly there are a few things to be fixed on the desktop version first. See road map section of the howto.txt file in the archive. The most burning issue is the so called overwrite issue that I want to be sorted out next. Say you have two copies of the same app (same name, label, versionName) but one of them has a patch against it (because its been modded by a reverser) than one of the copies will overwrite the other (ApkRename 1.10).
Secondly on a mobile device's SD card there is usually less space than on a desktop's hard drive. This implies that APK Renamer will actually have to rename the files in place instead of creating a copy of each in a separate folder. Or at least it will need to figure out the empty space left on the device, and if its not enough to hold the copies, it should offer in-place renaming instead. Not a lot of logic to add but still...
Having all the outstanding questions be figured out on the desktop still, will allow me to implement a more established version for the phone right from start. But hold still its not going to take very long
Bests,
phsorx
I'd like to get some ad blocking software that works under root; so what's the best thing out there?
I only run a modified hosts file and replaced the one that's in /system/etc/
amartolos said:
I only run a modified hosts file and replaced the one that's in /system/etc/
Click to expand...
Click to collapse
That must be a really large hosts file. Does the size of it slow down anything? If not can to share that file?
I googled for mine a while back, got it from a funny url like "someonewhocares.org" or something. No slowdowns whatsoever for me.
MoaAB: http://forum.xda-developers.com/showthread.php?t=1916098
I haven't noticed any slowdown.
I use Adaway