yashsingh1/xdaforums huggingface dataset:
[Android Software Development] gu5t3r:
Will look into it over the weekend =)
[Android Software Development] odo89:
Awesome
[Android Software Development] bauuuuu:
Its amazing..... although i checked with optipng which is used in e.g. apkmultitool and found that optipng was giving me even small sized apk ... is it because of compression level ? I used GOoptimize option default to compare
[Android Software Development] gu5t3r:
pngquant does only color reduction, and it does it better, with more quality than optipng,TruePNG and other...in fact it's the only tool that does it right...

I didn't want users to overreduce png colors by default, so I defaulted it to -q50

try manualgo

goptimize -p -q0 -zo APKNAME

png's will be smaller and still better quality than optipng...
[Android Software Development] bauuuuu:
Thanks for the tip, although it gave me same result as default option gave. What i see that the difference is quite substantial, with optipng i got reduced to 7.5 Mb from 13 Mb and with goptimize with all possibilities i got 11.8 Mb. Any hints ? i might be doing something different !
[Android Software Development] gu5t3r:
Here GOptimize v1.45-rc1, just replace goptimize.sh in /bin.

you can now keep multiple libraries, e.g. -k12 or -k35

test it...
[Android Software Development] Nikomoro:
Have you tried to use these arguments in "aapt"?

What do you think about it?
[Android Software Development] ct_moi:
Hello,

Try some test on 1.45-rc1 and got an error:

[E] <[ Adaway.apk ]> CORRUPTED during GOptimization!!!

I've got the error when I add -k6 to keep arm64-v8a, it working with other values in -k.

Does it support also -b23 ?

Thanks -

Eric
[Android Software Development] gu5t3r:
$ goptimize -p9zo -q50 -e- -Ei -d6 -b23 -k6 AdAway.apk

[+] GOptimizing: <[ AdAway.apk ]>
|- Cleaning resources of unneeded languages...
| | ...with ApkTool v2.1.0
| |- Removing unneeded languages...: Success!
| +- Attempting to assemble APK....: Success!
|- Removing libraries for: armeabi, mips, mips64, x86
| + Keeping for: [arm64-v8a]
|- Extracting APK...
|- Optimized PNG's: 100% | Saved: 46 kB (24%)
|- Removing debug info; smali v2.1.1: Success!
|- Recompressing classes.dex with CL(6)
+- Zipaligning APK...

Maybe it's file permission errors, try running as admin?
[Android Software Development] -->:
I know this is a stupid question (because it is already stated in the first page).

I'm just curious, is this script work with the real BASH too?
[Android Software Development] gu5t3r:
It would need modification in order to work with Linux BASH, script would needed to be modified for unix paths...

TruePNG would need wine to run as there is no linux version...
[Android Software Development] ct_moi:
Hi,

I'm running as admin but always same error but arm64-v8a lib are in apk

goptimize -e 'fr' -Ei -pczo -j75 -a0 -d5 -b23 -l5 -k6 *.apk;

[+] GOptimizing: <[ org.adaway_56.apk ]>
|- Cleaning resources of unneeded languages...
| | ...with ApkTool v2.1.0
| |- Setting up frameworks...
| |- Removing unneeded languages...: Success!
| +- Attempting to assemble APK....: Success!
|- Removing libraries for: armeabi, mips, mips64, x86
| + Keeping for: [arm64-v8a]
|- Extracting APK...
|- Optimized PNG's: 100% | Saved: 27 kB (24%)
|- NO JPG's in APK detected
|- Storing resources.arsc uncompressed
|- Removing debug info; smali v2.1.1: Success!
|- Recompressing classes.dex with CL(5)
|- Recompressing libraries with CL(5)
[E] <[ org.adaway_56.apk ]> CORRUPTED during GOptimization!!!
+- Zipaligning APK...
[Android Software Development] kpirnie:
[MENTION=4665716]gu5t3r[/MENTION]

Hey mate... been awhile :D

Got a question for you. Does this log anything anywhere? I'm asking because I applied this to one particular APK, that reported it was "corrupted", however, I went and reflashed it anyways (it was a system app), and it worked just fine... so I'm just curious to see if I can find something that can direct me to what in particular was "corrupted"?

TIA
[Android Software Development] gu5t3r:
I only have pause option on removing languages from resources -e if you add -Eppp

Script checks for corruption by counting files and folders in apk, but some zip packers add folder also as file so it is counted twice...

Try to check folder and file number before and after in 7-zip on info button.
[Android Software Development] Linuxx84:
Very nice tool guys! I tested with various system apps and works like a charm. But I noticed that a lot non-system app after optimized says "Application not installed". Why? Example, with tapatalk and whatsapp zero problem. I can install them.
[Android Software Development] jajk:
[MENTION=4665716]gu5t3r[/MENTION] Firstly a big thanks for the great tool:good: I have been using it ever since needing it to squeeze 4.4 onto a Samsung Galaxy Mini.

Is there a way of making the remove languages option aware of resources described in this form: zh-CN, zh-TW etc. Currently, it seems to look at the first pair of letters so leaves some languages behind.

Example: needed language is zh - it will leave zh, zh-CN and zh-TW resources behind.

Also... the remove lib function has a limitation in that, say I want to remove everything except arm64 but only if arm64 libs exist - otherwise I need to keep armv7 or armeabi libs. Is it possible to have a conditional function added to do this?

Edit: that should read zh-rCN, zh-rTW etc.
[Android Software Development] Linuxx84:
Now I noticed that tapatalk and whatsapp optimized says "App non installed" i I try to reinstall. Why this issue?
[Android Software Development] Windows X:
Anybody tested GOptimize with latest Play Store on Android Marshmallow? It crashed Google Play services during setup.
[Android Software Development] ct_moi:
api 25 remove debug info

Hi,

I've update apktool, basksmali & smali to last version also change line 291 of goptimize.sh to:

if [[ ! "$opt_b" =~ ^[1-9]$ && ! "$opt_b" =~ ^1[0-9]$ && ! "$opt_b" =~ ^2[0-5]$ || ! "$opt_d" ]]; then

but I can't remove debug info from classes.dex (api 25), it always failed.

Did I need to change something else ?

Other than that, still working like a charm on 7.1.1.

Thanks -

Eric
[Android Software Development] methuselah:
Lol .....my fault ...when i saw something like that i just ran out to see it for android ...
[Android Software Development] yao85930101:
Thanks for sharing:good:
[Android Software Development] gu5t3r:
After some testing, same APK's with compressed resources.arsc use more ram for about the size of resources.arsc

My guess is that probably asset manager needs to decompress resources.arsc in ram...

So system apk's and apps like FaceBook, Viber, Whatsapp & Widgets should always have resources.arsc uncompressed as they are always running in background when you're doing nothing with phone...
[Android Software Development] vishal_android freak:
As far as I know, they run in background because its an instant messaging app and if its not continuously running, we won't receive messages as soon as they are sent to us.. Right?:confused:
[Android Software Development] gu5t3r:
Yes...

Only apps that truly use Google Push Message system are IM+ and Tapatalk 4. They don't consume memory while they are in background...

It's main reason for me why I prefer IM+ over imo... imo uses 10MB of ram constantly even if you don't use it... IM+ uses <1MB while in background...
[Android Software Development] gu5t3r:
UPDATE 2013-09-13 v1.21

Further improved MT PNG optimization

Added -s2 option so you can try removing debugging info using smali/baksmali v2 beta if default v1.4.2 fails

ReWorked compression levels; Read Extra Help; -he or -hh option

Updated TruePNG to 0.4.0.8

Updated CygWin Tools

Lots of "can't remember right now" minor fixes

Next to do thing is probably APK ReSigning so you don't need to have ROM patched or ReSign APK's for installing normal apps.

But I find it easier to patch ROM using Lucky Patcher not to check signatures...
[Android Software Development] lolet:
Hey, great tool. Could you add a feature to keep resources for single dpi? eg. if framework-res.apk contains wallpapers for ldpi, hdpi, etc. it'd keep only hdpi, but if ldpi contains file which doesn't have hdpi it will keep it as well.
[Android Software Development] gu5t3r:
Don't have time right now but I will give it a try next month.

There are so many drawable folders so it will be complicated...
[Android Software Development] gu5t3r:
Changelog:

2013-09-22 v1.22

Added -t option to sign apk with Android test certificate so you can install goptimized apk's (Java configuration required)
[Android Software Development] akuila:
i don't really understand about this stuff yet i wanna try it,

is this : -m8 -zb -a0 -d5 -b15 -k1 -l5 -r5 *.apk; good enough to get both optimized png and compressed for system and non system apk ?
[Android Software Development] gu5t3r:
Yes...

-b15 is removing debugging info for ICS

-k1 will remove all libs except for armeabi (check that you don't need armeabi-v7a)

For non system apps you need to use -t option or patch rom with Lucky Patcher not to verify signatures...
[Android Software Development] akuila:
then how about CM 10.1 ?

apparently, i'm using it on cm 10.1, looks like it doesn't reduce the size pretty well, i mean, the size reduced was small compared to apk multi tool with optimized png + zipalign.

right now my free space on system is 26 MB with 73 apk files, i can't odex all of them, need more compression, could you give me a suggestion?

over all, i'm satisfied enough with this tools :victory:, its was easy to use and with only 1 click :p, do all the job while i'm enjoying a cup of tea
[Android Software Development] gu5t3r:
My script optimizes png's better but multi-apktool compresses resources.arsc which results smaller files but more ram usage because android asset manager needs to decompress resources.arsc before accessing it (which it doesn't when it's uncompressed)

you can try -a1 option to light compress resources.arsc (instead -a0)

all Google Play apps have resources.arsc uncompressed except FaceBook because it's 7MB (2MB compressed)

and when I uncompress resources.arsc FB starts faster....
[Android Software Development] gu5t3r:
If you need space for apps use Mounts2SD for sd-ext...
[Android Software Development] akuila:
hmm it's true, i feel this more faster than i do optimizing and compress with apk multi tool

well, i still can use the phone without odexing them

and i already use a2sd

thank you for your advice.
[Android Software Development] gu5t3r:
NP

I also started with using APK Multi Tool but I didn't liked the way it worked. Even when author added option to choose separate compression level for resources.arsc it didn't worked, so I started creating my own script to un-compress resources.arsc. Then, I've done a little research and found a way to optimize PNG's better and reduce it's size even more and stopped using AMT. (Best test between optimizing in my script and in apk multi tool is to check uncompressed sizes; info button in winrar, total size row; info button in 7-zip, size row)

AMT is good tool for modding apps, but its limitation is that it uses Windows Batch for scripting which is very limited.

It could do much more in BASH scripting.
[Android Software Development] hertzschi:
Nice Tool :good:

I achieved compression of my themes of -20% :D

Just one question:

If I GOptimized my theme/app and then later decompile, modify and compile again: do I have to GOptimize it again?

Thanks
[Android Software Development] gu5t3r:
Only if you add new PNG's...
[Android Software Development] algarues:
Sorry for the silly question

but before using the script I read the thread, and wonder myself (after the discussion on the .jar files)

If I have to use the script on deodexed apps only or I can use it on the apk portion of the app when it is odexed?

Thanks a lot for the info
[Android Software Development] gu5t3r:
You can... but you can't remove debug info from odexed jar because there is no dex file in it...
[Android Software Development] BullGates:
Great tool thanks! I've found many apk's with thumbs.db file hidden in it. If you use jpegtran on the jpg files, you may also reduce a lot of size.
[Android Software Development] gu5t3r:
Well, it's jpegtran -optimize feature looks promising for reducing few more kBs

Thanks =)

Will try on an apk and see if android has problem with optimized jpgs...
[Android Software Development] gu5t3r:
Do you know any APP with JPG's?
[Android Software Development] algarues:
Thank you

In case of a user app should I use -b with the number of my phone API level or with the highest API level number for which the app is written?
[Android Software Development] gu5t3r:
I use API Level of my Rom, 15 for ICS...

I made removing debugging info Fail-Safe, if there are any errors in the process script will inform you that removing debug info is failed and revert to original classes.dex...

Didn't test lower API Levels...
[Android Software Development] gu5t3r:
Found even better tool for optimizing jpegs https://github.com/tjko/jpegoptim XD
[Android Software Development] gu5t3r:
Coming soon in v1.23 =)

$ goptimize -m4 -zb -j0 'Clean Master (Cleaner) v3.8.1.apk'

[+] GOptimizing: <[ Clean Master (Cleaner) v3.8.1.apk ]>
|- Extracting APK...
|- Optimized PNG's: 100% | Saved: 123 kB (19%)
|- Optimized JPG's: 100% | Saved: 31 kB (6%)
+- Zipaligning APK...
[Android Software Development] Madaditya:
I get this error

##########[ MiniCygwin GOptimize v1.22 ]###########

[i] Put APK's in "PlaceApksHere"
and press any key to start...

[+] GOptimizing: <[ Facebook.apk ]>
|- Extracting APK...
|- Optimized PNG's: 100% | Saved: 532 kB (18%)
|- Packing PNG's in APK...
|- Storing resources.arsc uncompressed
|- Removing debugging info from classes.dex using smali
[w] Failed Removing debugging info...
|- Recompressing classes.dex with CL(5)
|- Recompressing libraries with CL(5)
|- Signing APK with Android test certificate
java.lang.NullPointerException
at s.IOUtils.copyLarge(IOUtils.java:61)
at s.IOUtils.copy(IOUtils.java:49)
at s.IOUtils.toByteArray(IOUtils.java:39)
at s.Sign.<clinit>(Sign.java:393)
java.lang.NullPointerException
at s.IOUtils.copyLarge(IOUtils.java:61)
at s.IOUtils.copy(IOUtils.java:49)
at s.IOUtils.toByteArray(IOUtils.java:39)
at s.Sign.<clinit>(Sign.java:396)
java.lang.NullPointerException
at java.io.ByteArrayInputStream.<init>(Unknown Source)
at s.Sign.readPublicKey(Sign.java:78)
at s.Sign.sign(Sign.java:435)
at s.Sign.main(Sign.java:532)
+- Zipaligning APK...
Unable to open 'Facebook.apk' as zip archive
mv: cannot stat `Facebook.apk.zipa': No such file or directory

[i] Press any key to exit...

Is it Java config error? i did configure it properly

also tried removing '-b'(remove debugging) option but some error with testkey
[Android Software Development] gu5t3r:
Try removing new line character from bin/.JavaPATH if you have it, if you still get error then Java version is to low or Java is incorrectly installed.

Try installing latest Java 1.7, you will also have to put new Java bin path in bin/.JavaPATH if you had 1.6 or lower before...
[Android Software Development] gu5t3r:
Just checked if there is new line after Java bin path it does not recognize Java at all

Edited script to read only first line if there are multiple lines in bin/.JavaPATH

Will be fixed in v1.23, for now if you have new line in .JavaPATH remove it

But, I still think your problem is bad Java installation or old Java version

You should always edit GOptimize files with Notepad2 or Notepad++ because windows notepad does not recognize unix files correctly...
[Android Software Development] Madaditya:
i dont have a newline in .Java PATH and i do use Notepad++

this' what my java folder looks like

I Gave path as

C:\Program Files\Java\jre7\bin

and also tried

C:\Program Files\Java\jre6\bin

manualGo.cmd detects 'which java' and gives the right path though!

BUt have the Same Problem!
[Android Software Development] gu5t3r:
Can you enter in ManualGO

sign

and

java -jar "$(cygpath -wal "/bin/sign.jar")"

and

cygpath -wal "/bin/sign.jar"
[Android Software Development] gu5t3r:
Changelog: 2013-09-25 v1.23

Added -j option to optimize jpg images in apk using jpegoptim

-j0 is lossless optimization and is recommended; it only strips unnecessary info from jpg (like which app is used to create it) and optimizes huffman coding

If you want to lower jpg's size even more, use -j95 which will recompress jpg's (and optimize) that are unnecessary big and only perform lossless optimization on others.

Every JPG compression guide agrees that compression level above 95 is pointless and creates unnecessary big jpg's.

I also left you choice to choose compression level between [75-100]

Reworked code for APK recompressing for easier adding of file extensions/formats that should always be uncompressed

Also added zip and lzma to that list

Improved reading Java bin path from bin/.JavaPATH

Removed "Packing PNG's" info line after optimizing pngs; don't worry, optimized png's are still packed in apk

$ goptimize -j0 *.apk

[+] GOptimizing: <[ Clean Master (Cleaner) v3.8.1 build 30810406.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 31 kB (6%)
+- Zipaligning APK...

$ goptimize -j95 *.apk

[+] GOptimizing: <[ Clean Master (Cleaner) v3.8.1 build 30810406.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 31 kB (6%)
+- Zipaligning APK...

$ goptimize -j90 *.apk

[+] GOptimizing: <[ Clean Master (Cleaner) v3.8.1 build 30810406.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 44 kB (9%)
+- Zipaligning APK...

$ goptimize -j85 *.apk

[+] GOptimizing: <[ Clean Master (Cleaner) v3.8.1 build 30810406.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 85 kB (17%)
+- Zipaligning APK...

$ goptimize -j0 *.apk

[+] GOptimizing: <[ Facebook for Android v3.7 build 367848.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 10 kB (4%)
+- Zipaligning APK...

$ goptimize -j95 *.apk

[+] GOptimizing: <[ Facebook for Android v3.7 build 367848.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 20 kB (7%)
+- Zipaligning APK...

$ goptimize -j90 *.apk

[+] GOptimizing: <[ Facebook for Android v3.7 build 367848.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 56 kB (21%)
+- Zipaligning APK...

$ goptimize -j85 *.apk

[+] GOptimizing: <[ Facebook for Android v3.7 build 367848.apk ]>
|- Extracting APK...
|- Optimized JPG's: 100% | Saved: 87 kB (33%)
+- Zipaligning APK...
[Android Software Development] BullGates:
Hi gu5t3r, that was fast! Thank you very much for implementing, I will try it.
[Android Software Development] gu5t3r:
=) Only thing I forgot to add jpe and jfif extensions to jpg list (script now searches for jpg and jpeg)

but that shouldn't be problem as all apps i tried use jpg

Will be in v1.24 =)
[Android Software Development] Madaditya:
And this' is what i get!

:(

Desktop@Desktop-PC /PlaceApksHere
$ sign
java.lang.NullPointerException
at s.IOUtils.copyLarge(IOUtils.java:61)
at s.IOUtils.copy(IOUtils.java:49)
at s.IOUtils.toByteArray(IOUtils.java:39)
at s.Sign.<clinit>(Sign.java:393)
java.lang.NullPointerException
at s.IOUtils.copyLarge(IOUtils.java:61)
at s.IOUtils.copy(IOUtils.java:49)
at s.IOUtils.toByteArray(IOUtils.java:39)
at s.Sign.<clinit>(Sign.java:396)
Usage: java -jar sign.jar my_1.apk [my_2.apk ...] [--override]

Desktop@Desktop-PC /PlaceApksHere
$ java -jar "$(cygpath -wal "/bin/sign.jar")"
java.lang.NullPointerException
at s.IOUtils.copyLarge(IOUtils.java:61)
at s.IOUtils.copy(IOUtils.java:49)
at s.IOUtils.toByteArray(IOUtils.java:39)
at s.Sign.<clinit>(Sign.java:393)
java.lang.NullPointerException
at s.IOUtils.copyLarge(IOUtils.java:61)
at s.IOUtils.copy(IOUtils.java:49)
at s.IOUtils.toByteArray(IOUtils.java:39)
at s.Sign.<clinit>(Sign.java:396)
Usage: java -jar sign.jar my_1.apk [my_2.apk ...] [--override]

Desktop@Desktop-PC /PlaceApksHere
$ cygpath -wal "/bin/sign.jar"
E:\Sonu\Android-Root\Tools\Apk EDits!\Go Optimizer\MiniCygwin_GOptimize_v1.22\bi
n\sign.jar

Desktop@Desktop-PC /PlaceApksHere
$

Edit:Post #57 Worked!

Just Placed 'Goptimizer' with its parent folder and all works!
[Android Software Development] ct_moi:
Hi,

Have you try to put the root of E:\ ? (just e:\goptimize)

I saw it's a long way and a "!" in the way.

Running here perfectly on win7 but 32bit java version.
[Android Software Development] gu5t3r:
Problem is 100% in

!

in PATH...
[Android Software Development] gu5t3r:
I found solution, it's to turn history expand off...

v1.24 will work in your path...

:victory::p:laugh:
[Android Software Development] gu5t3r:
Changelog: 2013-09-26 v1.24

Added jpe and jfif extensions to search list when optimizing jpg's which now is: jpg, jpeg, jpe, jfif.

Found and FIXED bug where files with no extension were not recompressed on -r option

ReWorked some compression code for easier reading and editing

Paths containing '!' (exclamation mark) will no longer be problem for script.

Minor code improvements...

You can now write -zo instead -zb if you like, it's easier for me =)

Updated smali v2 to 2.0b6 which can now remove debug info from some *****y classes.dex which smali 1.4.2 and 2.0b5 couldn't.
[Android Software Development] andrman1:
Hello,

What effects on Android will fast running than ever or save spacer actually what helps?
[Android Software Development] murad052:
its take a lot of time for APk 31 MB size . is that normal ..

I tried it on game apk . its toke 1.3 mb away , but when i tried to install it but no success

maybe its just working on apps not games
[Android Software Development] :
Yep it does both but 10%-25%

Who told u to do it with game's file, nope it will not work, game use alot of graphic file that why it took you long time to complete
[Android Software Development] octolith:
Hello,

I have a few questions. But first, I'll share my configuration. My phone is a Samsung GT-I9000 Galaxy S which is infamous for it's low I/O speeds. That's why I decided to try your tool. My phone is running a stock ODEXED gingerbread 2.3.6 rom. Since almost all the system apps won't get updated anymore, I decided to use the tool on almost all apks in my system/apps folder.

I plan to overwrite the apps in my system/apps folder with the optimized ones. I plan to do this from recovery, either by using AROMA file manager or an own flashable zip. As far as I understand, if I use resigning with your tool, it shouldn't be a problem in theory (if I wipe cache and dalvik-cache). Is this correct?

If I use your tool on user apps, can I install the apks directly, or I'll have to uninstall the original ones first?

And lastly: I read before, that someone used this on framework.jar. Since my phone is ODEXED, will I have any benefit from using the tool on that file (renaming it to .apk)? Also: can I use it on framework apks? (framework-res.apk and twframework-res.apk in system/framework)

Just a little comment from me: it took me quite a bit of time to figure out what to modify to make the tool run as I wanted it to, the instructions in the first post weren't very clear for me :)

Thank you for reading this and thank you in advance for your reply!

Have a nice weekend! :)

P.S. Sometimes it gives an error like this:

|- Extracting APK...

[\] Optimizing PNG's: 69%stat: cannot stat `./res/drawable-hdpi/msg_bubble_attac

h_icon.pngz0pfl1': No such file or directory

/bin/goptimize: line 263: [: : integer expression expected

|- Optimized PNG's: 100% | Saved: 40 kB (14%)
[Android Software Development] gu5t3r:
Less size, less ram usage, faster read/access...

And every kB saved on removing debug info is directly saved ram as dex file is mapped(copied) into ram memory...

Games usually have textures and not much png and jpg files, so you won't get much percentage saved...

But it should work, did you signed the game after procesing?

Which options did you used?

If you used recompress option, I didn't add some extension (to script list) that games should have uncompressed in apk

I'm making smart recompress i.e. only recompress files that were compressed in original apk and leave others uncompressed (as they are uncompressed with reason)

It's in testing and will be in new version of script =)