Post Reply

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

OP bravomail

26th March 2012, 03:22 PM   |  #1  
bravomail's Avatar
OP Senior Member
Flag Detroit
Thanks Meter: 338
 
949 posts
Join Date:Joined: Jan 2011
More
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
Last edited by bravomail; 31st May 2012 at 05:08 PM.
The Following 13 Users Say Thank You to bravomail For This Useful Post: [ View ]
26th March 2012, 03:40 PM   |  #2  
jellette's Avatar
Recognized Developer
Flag Tulsa, Oklahoma
Thanks Meter: 1,464
 
1,410 posts
Join Date:Joined: Sep 2010
Donate to Me
More
Nice, I will check this out tonight.
26th March 2012, 07:30 PM   |  #3  
DAGr8's Avatar
Recognized Developer
Montreal
Thanks Meter: 6,332
 
3,525 posts
Join Date:Joined: Feb 2010
Donate to Me
More
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 .
26th March 2012, 11:01 PM   |  #4  
TheATHEiST's Avatar
Senior Member
Flag Hull
Thanks Meter: 893
 
4,094 posts
Join Date:Joined: Sep 2008
Can this only be used on roms or can I use it on my collection of apk files for side-loading?
The Following User Says Thank You to TheATHEiST For This Useful Post: [ View ]
27th March 2012, 01:08 PM   |  #5  
ak's Avatar
Recognized Contributor
Flag Ak Land Valley
Thanks Meter: 44,540
 
10,729 posts
Join Date:Joined: Feb 2011
Donate to Me
More
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.
29th March 2012, 08:51 PM   |  #6  
bravomail's Avatar
OP Senior Member
Flag Detroit
Thanks Meter: 338
 
949 posts
Join Date:Joined: Jan 2011
More
Usage: MainScript.bat sign|sys repack|process

Quote:
Originally Posted by DAGr8

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 .

The Following User Says Thank You to bravomail For This Useful Post: [ View ]
29th March 2012, 08:52 PM   |  #7  
bravomail's Avatar
OP Senior Member
Flag Detroit
Thanks Meter: 338
 
949 posts
Join Date:Joined: Jan 2011
More
Quote:
Originally Posted by TheATHEiST

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.
The Following User Says Thank You to bravomail For This Useful Post: [ View ]
29th March 2012, 08:54 PM   |  #8  
bravomail's Avatar
OP Senior Member
Flag Detroit
Thanks Meter: 338
 
949 posts
Join Date:Joined: Jan 2011
More
Enable "echo" and redirect output to log file. If you can do that - you will succeed in any scripting!

Quote:
Originally Posted by anarkia1976

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.

The Following User Says Thank You to bravomail For This Useful Post: [ View ]
30th March 2012, 08:42 AM   |  #9  
ak's Avatar
Recognized Contributor
Flag Ak Land Valley
Thanks Meter: 44,540
 
10,729 posts
Join Date:Joined: Feb 2011
Donate to Me
More
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.
30th March 2012, 05:55 PM   |  #10  
bravomail's Avatar
OP Senior Member
Flag Detroit
Thanks Meter: 338
 
949 posts
Join Date:Joined: Jan 2011
More
It works on framework-res.apk for Galaxy S family. Make sure input file works before processing it. Remember - garbage in/garbage out rule.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Android Software and Hacking General [Developers Only] by ThreadRank