5,599,977 Members 44,843 Now Online
XDA Developers Android and Mobile Development Forum

[SCRIPT][Windows7-64]ROM and APK Compressor v3

Tip us?
 
bravomail
Old
(Last edited by bravomail; 31st May 2012 at 05:08 PM.)
#1  
bravomail's Avatar
Senior Member - OP
Thanks Meter 335
Posts: 933
Join Date: Jan 2011
Location: Detroit
Lightbulb [SCRIPT][Windows7-64]ROM and APK Compressor v3

So here is the latest version of Windows batch script which will process apk, zip and jar files. I used it to successfully create 3 ROMs based on Froyo, GB and ICS.

Changes to v3 - files and paths with spaces should work fine. 64 to 16 colors disabled.

Changes to v2 - 64 color images color quantized to 16 (can be disabled in code). Theme copied files are resized to match destination png size, which helps with hdpi folder going to xhdpi. Mulithreaded pngcrush - splits png filelist into number of CPUs.

It processes PNG, JPG, OGG and MP3 files with lossy compression, to reduce color depth to 256 or apply mono bitrate 64kbps sample rate 22kHz to sounds.

It runs without human interaction. It is not very fast, and cannot be run concurrently as several threads due to temporary files being used as variables, and imageq.exe (cq.exe) logic for dithering PNGs and unable to run as several instances (it's GUI Windows app).

Source themed application resources are copied into target directory to preserve theming with new code.

Resulted resources then repacked using Kzip for deflated resources and 7-zip for stored resources. Input file structure kept, so what came as stored, will be stored, so framework apks and jars are safely processed.

Typical workflow to process ROM zip-file would be to put apks and jars into ./place-apk-here-to-batch-optimize . And any themed apks into ./place-apk-src.

Then get results from %TEMP%\optimizedapk and put them back into ROM zip.
Next put ROM zip into ./place-apk-here-to-batch-optimize and run one more time to process media files in ROM itself, and have better KZip packing.

Then test.
Testing apks one-by-one is recommended in the beginning, since results cannot be guaranteed.

User (non system) apks also can be compacted to further improve system performance and reduce file sizes. Updating user apps from Market (G-Play) will then become a problem, because apks signed using test certificate. You have to uninstall/install from Market to solve it and you also will loose your pics/snds compression.

ffmpeg.exe/ffprobe.exe are only 64-bit apps here. You can try to replace them by 32-bit, but my attempts got always buggy ffmpeg.exe, so ...

To get slightly faster processing the whole folder can be copied to noncompressed RAMDisk (I use free IMDisk) and TEMP folder to be set to RAMDisk (R:\Temp for example).

rem *** credits - ApkManager 4.9, apkopt, ImageMagick, 7-zip, signapk, zipalign, PNGScript
REM *** Usage: MainScript.bat sign|sys repack|process
REM *** Incoming files are in "./place-apk-here-to-batch-optimize" DIR
REM *** Source files with themed pictures/sounds are in "./place-apk-src" DIR
REM *** Incoming files cannot have spaces IN the name
REM *** Result is in "%TEMP%\optimizedapk" dir
REM *** Please check JAVA_HOME and TEMP variables!!! ***
REM *** "process" option performs lossy compression of PNG, JPG, OGG, MP3 and WAV files
REM *** result of "process" is up to 50% smaller apks, faster loading times, overall faster operation
REM *** Example to process(PNG) system apks: MainScript.bat sys process
REM *** Example to process(PNG) user apks: MainScript.bat sign process
REM *** Example to repack (Kzip maximum) system apks: MainScript.bat sys repack

Make your variables and Java path shorter and have no spaces (it helps with debugging):
SET TEMP=C:\TEMP
SET JAVA_HOME=C:\JAVA

Under "place-apk-here-to-batch-optimize" should be files with extensions .apk, .zip and .jar

If there are no files with those extensions - no error is produced.

To log errors - enable echo in zipb.cmd and run something like:
MainScript.bat sys process >out.txt 2>err.txt

Check out.txt and err.txt for messages.

Download links

http://www.mirrorcreator.com/files/1...ger3.zip_links
https://www.rapidshare.com/files/194...pkManager3.zip
http://www.crocko.com/5F118ABEE2764E...pkManager3.zip
http://bayfiles.com/file/bv7t/C3lhIm/ApkManager3.zip
http://www4.zippyshare.com/v/99557620/file.html
http://www.megashare.com/4295302
http://filerio.in/c15huoa7lows/ApkManager3.zip.html
http://www.sendmyway.com/t0f6u3i7o74...ager3.zip.html
http://glumbouploads.com/2ud88ardqdj2

Previous version links
http://www.mirrorcreator.com/files/0...ess2.zip_links

http://www.mirrorcreator.com/files/I...ress.zip_links
Author of Nostalgia 8 for ATT SGS3, 1.5, 2.3 and 4.0.4 ICS ROMs for Samsung Captivate. ROM and APK compressor.
The Following 13 Users Say Thank You to bravomail For This Useful Post: [ Click to Expand ]
 
jellette
Old
#2  
jellette's Avatar
Recognized Developer
Thanks Meter 1464
Posts: 1,410
Join Date: Sep 2010
Location: Tulsa, Oklahoma

 
DONATE TO ME
Nice, I will check this out tonight.
 
DAGr8
Old
#3  
DAGr8's Avatar
Recognized Developer
Thanks Meter 6314
Posts: 3,484
Join Date: Feb 2010
Location: Montreal

 
DONATE TO ME
interestign , can you remove the signature option .

I mean I dotn want it to resign every apk , its not needed either . and coudl cause problems for themes that are usable on more then one rom .
COME CHAT WITH US

T W I T T E R
 
King-Kang For The Galaxy Note LTE

The Hybrid for Galaxy Note II & SGH-I717


SAUROM-PROJEKT for I9000


or

 
TheATHEiST
Old
#4  
TheATHEiST's Avatar
Senior Member
Thanks Meter 870
Posts: 3,948
Join Date: Sep 2008
Location: Hull
Can this only be used on roms or can I use it on my collection of apk files for side-loading?
Phone:
Galaxy Note II | CM11 (Unofficial)

Tablet
Nexus 7 | CM 10.2

Smartphone History:
HTC Touch > HTC Universal > HTC Touch HD > HTC HD2 > iPhone 4S > Samsung Galaxy S2 > Samsung Galaxy Note II

Tablet History:
Galaxy Tab 7.0 > iPad3 > Nexus 7

The Following User Says Thank You to TheATHEiST For This Useful Post: [ Click to Expand ]
 
ak
Old
#5  
ak's Avatar
Recognized Contributor
Thanks Meter 36096
Posts: 8,447
Join Date: Feb 2011
Location: Ak Land Valley

 
DONATE TO ME
Question Info

I replaced ffmpeg with the 32-bit exe, and i tried to optimize framework-res, everything works except at the end of the process there isn't apk file into the folder "optimizedapk".

PC:
windows7 32bit

The steps used are:
- SET TEMP = C: \ Users \ xxxx \ Desktop \ ApkCompress \ TEMP
- Set JAVA_HOME = C: \ Windows \ System32 \ config \ SystemProfile \ AppData \ LocalLow \ Sun \ Java \ jre1.6.0_29
- Put files into "place-apk-here-to-batch-optimize" -> framework-res
- Run MainScript.bat process sys

I have no clear error.

You have to give me some help?

Thanks you very much.



AK
Website: link

Github: link
Twitter: link
Xda N4: link
Xda N7: link
Google+: link
Dirty_v GN: link
Nephilim: link

I do NOT answer technical questions via PM.
Post your question in the correct thread if you want a response.
by morfic:
Just flash over.
Only thing we wipe here is our butts!


 
bravomail
Old
#6  
bravomail's Avatar
Senior Member - OP
Thanks Meter 335
Posts: 933
Join Date: Jan 2011
Location: Detroit
Usage: MainScript.bat sign|sys repack|process

Quote:
Originally Posted by DAGr8 View Post
interestign , can you remove the signature option .

I mean I dotn want it to resign every apk , its not needed either . and coudl cause problems for themes that are usable on more then one rom .
Author of Nostalgia 8 for ATT SGS3, 1.5, 2.3 and 4.0.4 ICS ROMs for Samsung Captivate. ROM and APK compressor.
The Following User Says Thank You to bravomail For This Useful Post: [ Click to Expand ]
 
bravomail
Old
#7  
bravomail's Avatar
Senior Member - OP
Thanks Meter 335
Posts: 933
Join Date: Jan 2011
Location: Detroit
Quote:
Originally Posted by TheATHEiST View Post
Can this only be used on roms or can I use it on my collection of apk files for side-loading?
User (non system) apks also can be compacted to further improve system performance and reduce file sizes. Updating user apps from Market (G-Play) will then become a problem, because apks signed using test certificate. You have to uninstall/install from Market to solve it and you also will loose your pics/snds compression.
Author of Nostalgia 8 for ATT SGS3, 1.5, 2.3 and 4.0.4 ICS ROMs for Samsung Captivate. ROM and APK compressor.
The Following User Says Thank You to bravomail For This Useful Post: [ Click to Expand ]
 
bravomail
Old
#8  
bravomail's Avatar
Senior Member - OP
Thanks Meter 335
Posts: 933
Join Date: Jan 2011
Location: Detroit
Enable "echo" and redirect output to log file. If you can do that - you will succeed in any scripting!

Quote:
Originally Posted by anarkia1976 View Post
I replaced ffmpeg with the 32-bit exe, and i tried to optimize framework-res, everything works except at the end of the process there isn't apk file into the folder "optimizedapk".

PC:
windows7 32bit

The steps used are:
- SET TEMP = C: \ Users \ xxxx \ Desktop \ ApkCompress \ TEMP
- Set JAVA_HOME = C: \ Windows \ System32 \ config \ SystemProfile \ AppData \ LocalLow \ Sun \ Java \ jre1.6.0_29
- Put files into "place-apk-here-to-batch-optimize" -> framework-res
- Run MainScript.bat process sys

I have no clear error.

You have to give me some help?

Thanks you very much.
Author of Nostalgia 8 for ATT SGS3, 1.5, 2.3 and 4.0.4 ICS ROMs for Samsung Captivate. ROM and APK compressor.
The Following User Says Thank You to bravomail For This Useful Post: [ Click to Expand ]
 
ak
Old
#9  
ak's Avatar
Recognized Contributor
Thanks Meter 36096
Posts: 8,447
Join Date: Feb 2011
Location: Ak Land Valley

 
DONATE TO ME
it works for all apks except framework-res.
Some png after compression on ICS 4.0.3 are corrupted but your work is great.
Thanks a lot.



AK
Website: link

Github: link
Twitter: link
Xda N4: link
Xda N7: link
Google+: link
Dirty_v GN: link
Nephilim: link

I do NOT answer technical questions via PM.
Post your question in the correct thread if you want a response.
by morfic:
Just flash over.
Only thing we wipe here is our butts!


 
bravomail
Old
#10  
bravomail's Avatar
Senior Member - OP
Thanks Meter 335
Posts: 933
Join Date: Jan 2011
Location: Detroit
It works on framework-res.apk for Galaxy S family. Make sure input file works before processing it. Remember - garbage in/garbage out rule.
Author of Nostalgia 8 for ATT SGS3, 1.5, 2.3 and 4.0.4 ICS ROMs for Samsung Captivate. ROM and APK compressor.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes