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

Search This thread

bravomail

Senior Member
Jan 12, 2011
1,003
351
Detroit
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/1ANFPIKS/ApkManager3.zip_links
https://www.rapidshare.com/files/1942139318/ApkManager3.zip
http://www.crocko.com/5F118ABEE2764E0FAC81411D89181C39/ApkManager3.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/t0f6u3i7o74r/ApkManager3.zip.html
http://glumbouploads.com/2ud88ardqdj2

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

http://www.mirrorcreator.com/files/IUH9FUMM/ApkCompress.zip_links
 
Last edited:

DAGr8

Inactive Recognized Developer
Feb 27, 2010
3,713
6,309
Montreal
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 .
 

ak

Senior Member
Feb 19, 2011
14,848
69,619
Ak Land Valley
ak.hiddenbytes.org
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.
 

bravomail

Senior Member
Jan 12, 2011
1,003
351
Detroit
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.
 
  • Like
Reactions: alexdoux25

bravomail

Senior Member
Jan 12, 2011
1,003
351
Detroit
Enable "echo" and redirect output to log file. If you can do that - you will succeed in any scripting! :)

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.
 
  • Like
Reactions: ak

bravomail

Senior Member
Jan 12, 2011
1,003
351
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. :eek:
 

ryude

Senior Member
Jun 19, 2010
2,812
766
USA
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.

I get the same result. Error says: "Cannot find storefilelist.txt"
 

bravomail

Senior Member
Jan 12, 2011
1,003
351
Detroit
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.

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.
 

nexten

New member
Sep 5, 2010
2
0
ok i guess i am having problems with this script, i have used another version of a apk manager and loved it from when i had the moto backflip to the samsung epic 4g so was always modding and hacking. but when i use this script i come up with the following errors any help would be appreciated

'C:\Users\Troy' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Troy' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Files of type "*.zip" not found.
 

bravomail

Senior Member
Jan 12, 2011
1,003
351
Detroit
Right. The script did not support spaces in file names, folders, or any of the path.
Now it does support those spaces (v3), I tested it with "Test file.zip", temp path and script path both containing spaces, PNGs with spaces and special characters like "[1]" in the name.

Try and see if it works for you! :D
 

Top Liked Posts

  • There are no posts matching your filters.
  • 13
    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/1ANFPIKS/ApkManager3.zip_links
    https://www.rapidshare.com/files/1942139318/ApkManager3.zip
    http://www.crocko.com/5F118ABEE2764E0FAC81411D89181C39/ApkManager3.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/t0f6u3i7o74r/ApkManager3.zip.html
    http://glumbouploads.com/2ud88ardqdj2

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

    http://www.mirrorcreator.com/files/IUH9FUMM/ApkCompress.zip_links
    1
    Can this only be used on roms or can I use it on my collection of apk files for side-loading?
    1
    Usage: MainScript.bat sign|sys repack|process

    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 .
    1
    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.
    1
    Enable "echo" and redirect output to log file. If you can do that - you will succeed in any scripting! :)

    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.