yashsingh1/xdaforums huggingface dataset:
[Android Software Development] jayOOMjay:
great , everything is working fine

I should thank you twice

1) for helping me with Goptimize and it is a handy tool :good:

2) For pointing out the usage of old winrar (big mistake ! I have been using that old one for a long time, Switched to 7zip the next moment I read your reply), I must have used 7zip from the beginning.
[Android Software Development] jayOOMjay:
the size of apk ,after doing the optimization using the default options ( "goptimize -p -q50 -j0 -a0 -d6 -l6 *.apk;" ) , is larger than the original one.

original = 717kb

optimized = 1232 kb

is that because of not doing -r Recompress APK with CL[0-6] ?
[Android Software Development] Madaditya:
Default options leave resources.arsc uncompressed option a0 I.e compress resources.arsc with level 0

Better on ram,makes apk light

Size is more coz its uncompressed or compressed with low value

Dont worry,its always smooth on performance
[Android Software Development] gu5t3r:
Is resources.arsc compressed in original apk? Try without -a0 to leave resources.arsc as it is....
[Android Software Development] swat4samp:
I got the following error while trying to remove unnecessary languages from my device's (galaxy fit) CM7 based rom.
[Android Software Development] jayOOMjay:
Yes, you were right, the resources.arsc was compressed in original apk. When tried without -a0 , the new apk is 5% smaller than the original :good:
[Android Software Development] gu5t3r:
Post link to apk and framework-res...
[Android Software Development] swat4samp:
https://www.dropbox.com/sh/yj1tumaji9myilk/AAAFWw6sZwiJMmxZlBp8YjD9a/Apps
[Android Software Development] gu5t3r:
$ goptimize -e- SystemUI.apk

[+] GOptimizing: <[ SystemUI.apk ]>
|- Cleaning resources of unneeded languages...
| | ...with ApkTool v2.0.0-RC1-848f0d6b5f
| |- Setting up frameworks...
| |- Removing unneeded languages...: Success!
| +- Attempting to assemble APK....: Success!
+- Zipaligning APK...

4 things you may have done wrong:

You left APK opened in 7-Zip or WinRAR (original or one from .go folder)

Your PATH is too long, put GOptimize in root of drive (this happens especially on FAT32)

Your PATH to GOptimize folder has weird characters.

There isn't enough space...
[Android Software Development] :
How is best options for optimalization images inside apk?
[Android Software Development] gu5t3r:
I use "-j75 -pzo -q40"

P.S. it is short for "-j75 -p -zo -q40"
[Android Software Development] swat4samp:
1) I closed apk files before using goptimize so there's no chance of it being open (even checked in task manager)

2) I replaced that folder on root of drive d but still gave me that error.

3) I don't know what does that mean. All i did was extract that zip file on the root of d drive.

4)There is over 10 gb space in that drive :D

Edit: I tried to run manualGO.cmd as administrator and now it's showing java not configured properly :crying: I already configured java and use eclipse to run java apps without any problem. So what else could be wrong with me? :confused:

Edit2: i forgot to enter java path in .javapath file and now i ran it as administrator and now i get this error

Here is dissasemble log
[Android Software Development] gu5t3r:
For some reason, ApkTool cannot access files... Set permissions for GOptimize directory to Everyone->Full Control on security tab...
[Android Software Development] swat4samp:
Thanks a lot for the tip mate. Now its working :good:
[Android Software Development] swat4samp:
[MENTION=4665716]gu5t3r[/MENTION] I was trying to remove unwanted languages in all system apps in cm11 rom and all of a sudden cmd window just went into infinite loop(/bin/goptimize :line 456: tr: command not found)

Edit: It just stopped and the next step it displayed removing unwanted languages as success and attempt to assemble apk as failed. Anything wrong?
[Android Software Development] gu5t3r:
Seems I didn't put tr.exe in bin folder, try to find tr.exe in older releases and put it to bin...

Will fix it in 1.40...
[Android Software Development] gu5t3r:
http://www.tusfiles.net/w7ibd1ezra0p

http://www52.zippyshare.com/v/26299351/file.html
[Android Software Development] gu5t3r:
When I was updating to new ApkTool output I used tr command to replace new lines with space and I didn't add it to bin...I will substitute it with awk, so tr won't be needed in 1.40 which I will probably release tomorrow with updated -Ei option which will try to integrate only required strings from required languages to try to make even smaller resources.arsc...
[Android Software Development] swat4samp:
One more bug which i observed after flashing rom. My hardware keys (menu and back) stopped working :eek: Only home key worked and with back key, i can only slide up notification panel. Strange issue i have never faced before. If i flash rom as it is, then it works fine. So is it unsafe to delete languages from all system apps? Can u tell me where might be the issue? I deleted all languages except en and never touched other options.
[Android Software Development] gu5t3r:
Never experienced the problem, but also 1.40 will have updated ApkTool from yesterday with bugfixes...

Until, you can also download new ApkTool from my devhost and put new apktool.jar to bin folder and try again...

Also I never remove languages from all files, just the one >100kB...

The biggest gain you get is by removing languages from framework-res.apk, Contacts.apk, Phone.apk, Settings.apk, SystemUI.apk....

Lots of users reported keyboard not working correctly when languages removed, LatinIME.apk...
[Android Software Development] swat4samp:
Okay then i will wait for the new version. Meanwhile, i will try to manually remove languages and check whether its problem with this tool or not. BTW i use ICS rom on my device having 280mb ram, before removing unnecessary languages, settings takes up nearly 60mb ram but after removing, it uses nearly 15-20mb. So thats the reason i used to delete languages.

If possible, can u make png optimization a bit faster? I tried to optimize framework apk and it took nearly 5-10 min :(
[Android Software Development] gu5t3r:
Can't make it faster (could but it would lower efficiency, so I wont; you don't do it every day =)... framework-res.apk is almost all png's...

With optimized pngs and removed languages my framework-res.apk went from 12.00MB -> 5.23MB
[Android Software Development] swat4samp:
Even my rom's framework-res too reduced from 10mb to ~4mb just by deleting unwanted languages :)

Thanks for the update. Will try and check if my problem is solved
[Android Software Development] swat4samp:
"Detecting required languages" feature is simply awesome dude :good: I think it solves problem where some apk's won't compile after removing unwanted languages which throws some string not defined errors.

Edit: After removing languages, i decompiled that particular app and found all the values folders as it is with no strings file in each folder except for wanted languages. Is it supposed to look that way?
[Android Software Development] gu5t3r:
Folders like values-?? without strings.xml should exist only if they have other *.xml file in it when using -Ei... (newest apktool versions automatically omit empty folders and they wont appear if you decompile apk again)

Always use latest ApkTool (apktool.jar) version, you can download it from my devhost...

Using ManualGO you can decompile/disassemble apks using "apktool" command so you don't have to setup separate environment for apktool and using "apktool" command you don't need to write java -jar apktool.jar...

Also, if you add 'p' to -E option, goptimize will pause after removing languages so you can see what is removed in GOATool/res-removed folder...

Example for pause: -e -Ep

Example for pause after and string integration -e- -Eip or -e- -Epi

I use pause function for testing, GOptimize continues on any key...

Also if you add two p, like -Eipp GOptimize will also pause before assemble test... I use this for Dolphin Browser as it needs fix in values-ja/arrays.xml (rakuton search url) so it could be assembled/compiled...

A lot of hours were spent to get GOptimize to detect required languages XD (also thanks goes to [MENTION=303041]ct_moi[/MENTION] for testing and debugging first steps =)
[Android Software Development] swat4samp:
Well i tried with latest version and still the problem persists :(. I dont know what's connection between removing languages and hardware keys function :confused: Will u tell me what apk might be related to the hardware buttons?? I will skip that particular apk.
[Android Software Development] gu5t3r:
Sorry, no one reported that problem before.... =(
[Android Software Development] swat4samp:
Thanks to [MENTION=5913734]xk0niR[/MENTION] , finally my problem is solved :). LatinIME is the reason behind it. Somehow Goptimize is breaking keyboard app which can't be accessed in rom. Replaced with original apk and everything's fine. You might add this point in OP.
[Android Software Development] Madaditya:
Goptimize on Xperia Keyboard

I have goptimized my Xperia Keyboard and removed unnecassary languages [ option -e- ]

Have no issues whatsoever,though i use only English Laungaue on my keybaord.

Thought would help. :)

[MENTION=4665716]gu5t3r[/MENTION] - I have a problem with -pzo option

When ever i use it,i see 5-6 instances of ZopfliPNG.exe running in the windows task manager,goptimizing hangs at a particular point and never completes.Tried waiting for some time but to no output,always have to terminate the process.

using just -p option works perfect.

what could be the issue? should i try assigning more cores to Goptimizer or something?
[Android Software Development] swat4samp:
It happened only with CM11 keyboard app. I tried on another rom and worked fine, so problem with some keyboards. Anyways, awesome tool :good:
[Android Software Development] gu5t3r:
On older versions zopflipng had a bug so it halted sometimes...Since I switched to Hello71 version of zopflipng now it works fine...

You can use now -pczo shortcut which means -p -c -zo...

-c means -q0 which means -q0-100

Posterizer is now replaced with PngQuant which is superior and you can apply it multiple times if max quality is 100 i.e. -q? or -q?-100

If you check change logs, pngquant is now also applied by default...

Avoid removing languages from keyboard XD
[Android Software Development] gu5t3r:
Figured out how I can optimize 9-patch ("*.9.png") png's in APK...

With posterizer it wasn't possible but now with PNGQuant it is =)

Saving 50-150kB more on png optimization per app =)

Update later today...
[Android Software Development] gu5t3r:
Updated to v1.41...

9-patch PNG's are now optimized by default, tested on Facebook with 100kB extra savings and Tapatalk with 90kB extra savings...

NO FC's in APPs...

To disable/skip optimizing 9-patch pngs use -9 option...

For max PNG optimization use -p -zo -q0 or in short -pczo (-c is equal to -q0)
[Android Software Development] swat4samp:
After using Goptimize, can i remove everything from tmp folder? Its occupying more space :o

Edit: Error while using -p -zo option..i copied only a part of error.
[Android Software Development] gu5t3r:
Yes, you can delete everything from /tmp folder, actually, goptimize should clear /tmp folder on start...

I don't have any errors with zopflipng, but I saw on original source they fixed some memory leak... Will compile and upload new binary...

Try to put this zopflipng (ae16c9e72766) (overwrite existing one) in /bin and see if you get the error...

http://www20.zippyshare.com/v/1279073/file.html

http://www.tusfiles.net/f1nln0v3rwah
[Android Software Development] swat4samp:
It's working now :good: But it's taking too long time to finish it (yesterday i tried -p and it took nearly 1 hour :eek: to complete)
[Android Software Development] gu5t3r:
zopflipng is used only when -z (-zo or -zz) option is used...

with -zo both pngout and zopflipng are used

with -zz zopflipng is used instead pngout (which is used asa default compressor for pngs)

why -pczo takes long time to complete is because every png is processed with:

1. pngquant (reducing colors to 256)

2. TruePNG (which is best png optimizer, better than optipng)

3. pngout (which is a compressor with KS-Flate algorithm)

4. zopflipng (which is compressor with zopfli algorithm)

Sometimes pngout gives better compression on some pngs, sometimes zopflipng, so processing every pngs with both gives maximum compression overall...

That is why choice is left to you, do you want maximum compression or fast one...
[Android Software Development] gu5t3r:
GOptimize v1.41 Re-Uploaded with new zopflipng binary, if you get zopflipng errors Re-Download...
[Android Software Development] gu5t3r:
ReUploaded GOptimize v1.41 again with new zopflipng version: 08b97947ac58 https://code.google.com/p/zopfli which includes more bug fixes...
[Android Software Development] ct_moi:
Hi,

Do you think than it's safe to optimize with v1.41 and v1.38 after, to use posterizer as some png are lighter with posterizer than pngquant.

I haven't look at the quality, but just the size.

Not much big diff, just do the test on my framework-res.apk (-9Ko), mediatek-res.apk (-7Ko) and systemui.apk (-21Ko).

Best regards - Eric
[Android Software Development] gu5t3r:
Hi, I would avoid that because with pngquant -q0-100 (aka -q0 aka -c )you can apply optimization a dozen of times and it would get you always same quality/size.

Each time you apply posterizer you get lower and lower quality and smaller and smaller size. If you really want that you can apply pngquant -q0-95 which will degrade quality by 5% each time you process APK...

pngquant always produces better quality pngs that posterizer, you just need to guess right -q0-?? value to get to your desired size...
[Android Software Development] gu5t3r:
Updated to v1.42 -=> https://app.box.com/gu5t3r
[Android Software Development] gu5t3r:
Reuploaded v1.42 with Auto Configure/Find Java Feature...

https://app.box.com/gu5t3r/1/2185758503
[Android Software Development] DSA:
This a great bit of kit, reduced my overall ROM size by over 50mb and everything runs nicer

Thanks for putting this into the community
[Android Software Development] gu5t3r:
If you're having problems removing debugging info from classes.dex try updated smali/baksmali
[Android Software Development] Paulo Narley:
[MENTION=4665716]gu5t3r[/MENTION] thank you for your work !!!

But tell me something, I do not worry myself with graphical quality but with my system performance, so besides removing liguagens what can I do to get the maximum advantage of focusing on performance? You could darme an example of code better than this standard:

(p goptimize -q50 -j0 -a0 d6 -l6 * apk) Thanks for your attention

-------------------------------------------------------------------------------------------------------------

Nexus 4 - MAHDI-ROM-2.7 + KERNEL Furnace-1.0.5 + MOD Fly On + Goptimeze
[Android Software Development] Paulo Narley:
[MENTION=4665716]gu5t3r[/MENTION] I'm testing this:

goptimize -p -m16 -zo -q0 -j0 -e- -a6 -d6 -b19 -s2 -l6 -rfb258 -R- -k2 -t *.apk

-------------------------------------------------------------------------------------------------------------

Nexus 4 - MAHDI-ROM + KERNEL 2.7 Furnace-1.0.5 + + MOD Fly On Goptimeze
[Android Software Development] gu5t3r:
XD

Then add "-Ei" after "-e-", it will try to integrate only required strings from required languages thus making resources.arsc even smaller XD

you don't need -m option as it automatically detects number of your cpu cores

you don't need -R option, it's for apk's that are messed up by other tools; goptimize will re-compress only already compressed files on re-compression, if unsure use "-R+"

you don't need -s2 as goptimize automatically uses smali2

you should store resources.arsc uncompressed (-a0) because app requires more ram & cpu when it' compressed
[Android Software Development] Venkatesh:
Could you please upload it to any other hosting site? Box is returning an error, atleast for me.
[Android Software Development] gu5t3r:
http://d-h.st/E7S
[Android Software Development] Venkatesh:
goptimize -p -9 -j0 -b *.apk command isn't working, even tried including -d5. Just shows help menu.
[Android Software Development] gu5t3r:
-b requires your sdk number

you can always use -b19 for non-system apps

https://developer.android.com/guide/topics/manifest/uses-sdk-element.html
[Android Software Development] Venkatesh:
so, i should do goptimize -b16 *.apk right? But, it is not working too.

Edit: goptimize -d5 -b16 *.apk is working.
[Android Software Development] AJM-hackers:
Could you possibly port this to linux? Most devs use linux. I for one have my computer with solely linux. Thanks!
[Android Software Development] hasan4791:
Awesome mate...Does this help us to reduce the size of apks in LG stock KK...??
[Android Software Development] gu5t3r:
Yes, works for all apks except keyboards.

Just download also newest apktool and smali from OP and replace in bin folder....
[Android Software Development] gu5t3r:
Don't have the time, also it would be complicated as there is no TruePNG for linux so you would still need to have wine...
[Android Software Development] ct_moi:
Hi,

I'm testing tool on N9005 and framework-res.apk.

Can't clean the lang, so I try to decompile with apktool.

In fact the problem is with <string name="mediaSize_iso_a0"/> in strings.xml values-mn

In values directory I've similar <string name="mediasize_iso_a0"/> only diff is the 'S'

I think than it doesn't make the diff with 's' and 'S' in the string name and may be the reason why it doesn't work.

(string value deleted by me)

Thanks
[Android Software Development] EvilMegaDroid:
[MENTION=4665716]gu5t3r[/MENTION]

Im getting disassemble test : Failed error when trying to run the script , i can disassemble the apk fine with apktool if i do it on its own , only with the script it does not work , i want to remove the unneeded language to make settings and systemUI smaller since my smartphone I/O is really slow and i want to optimize it a lil

Heres my disassemble.log file

I: Using Apktool 2.0.0-RC2-49afdd273d on GOTemp.apk

I: Loading resource table...

W: Skipping "android" package group

I: Loading resource table...

W: Skipping "android" package group

I: Decoding AndroidManifest.xml with resources...

Exception in thread "main" java.lang.NullPointerException

at brut.androlib.res.AndrolibResources.getFrameworkDir(AndrolibResources.java:742)

at brut.androlib.res.AndrolibResources.getFrameworkApk(AndrolibResources.java:614)

at brut.androlib.res.AndrolibResources.loadFrameworkPkg(AndrolibResources.java:123)

at brut.androlib.res.data.ResTable.getPackage(ResTable.java:75)

at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:58)

at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:54)

at brut.androlib.res.decoder.ResAttrDecoder.decode(ResAttrDecoder.java:36)

at brut.androlib.res.decoder.AXmlResourceParser.getAttributeValue(AXmlResourceParser.java:369)

at org.xmlpull.v1.wrapper.classic.XmlPullParserDelegate.getAttributeValue(XmlPullParserDelegate.java:69)

at brut.androlib.res.decoder.XmlPullStreamDecoder$1.parseManifest(XmlPullStreamDecoder.java:97)

at brut.androlib.res.decoder.XmlPullStreamDecoder$1.event(XmlPullStreamDecoder.java:65)

at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:141)

at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:153)

at brut.androlib.res.decoder.ResFileDecoder.decodeManifest(ResFileDecoder.java:131)

at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:295)

at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:123)

at brut.androlib.ApkDecoder.decode(ApkDecoder.java:102)

at brut.apktool.Main.cmdDecode(Main.java:170)

at brut.apktool.Main.main(Main.java:86)

Edit: Seems like the problem was that the tool does not work with the newest version of apktool , i resolved it by using a old version , sorry to bother you and thanks for this great tool
[Android Software Development] gu5t3r:
Will try to make GOptimize compatible with newest apktool over holidays....
[Android Software Development] EvilMegaDroid:
the tool seems to work with RC3 but non with RC2 and that is the lastest file on your link anyways i solved the prob of not disambling the problem im having now is that some roms for example the carboon rom for HD2 when you remove the unneded language settings.apk FC , dunno why , it works with other roms but as far as ive tried i can't get it wroking on kitkat roms
[Android Software Development] gu5t3r:
Compiled latest ApkTool RC3 and smali...

Seems it works fine....

Edit: Even extra integrating -Ei option works which detects only required strings/lines from languages we want to remove. Usually that are one or two strings from whole language and it helps reduce resource size even more....

Problem was that apktool wasnt able to recompile newer apps you were trying.... Dunno about KK apps.... Maybe it will work with latest RC3 now as they updated AAPT few days ago...
[Android Software Development] EvilMegaDroid:
ive tried RC3 and on KK removing strings from languages does not work , in JB works fine but sometimes it makes the settings.apk use more ram than normal, removing only the images makes them run faster and with less ram usage , maybe it is cuz im using a custom rom KK not the stock one
[Android Software Development] gu5t3r:
ApkTool Updated to 2014-12-26 (4882396163f978884256e008fc7fae9201f156b4)

https://www.mediafire.com/folder/7vv4unj5diiu2//ApkTool v2

https://app.box.com/gu5t3r/1/2185891971
[Android Software Development] joni2012:
No support Android lollypop and mm?

Team SkyDragon loving
[Android Software Development] kpirnie:
Works fine, but you have to update the baksmali, smali, and Apktool jars to the latest.

[MENTION=1007992]everyone[/MENTION] else:

I am having something strange happenning with this...

Can someone have a look at this line and see if something is outta place?

goptimize -p -k2 -9 -b -q50 -j95 -a6 -d6 -l6 -r6 frameworkapps/*.* >> log.txt;

yes frameworkapps exists is and is populated with the proper files.

Is log.txt is the help notice as shown on the OP... no errors.
[Android Software Development] gu5t3r:
-b requires api level i.e. -b21 (I think it's only used on system apps, but I forced users to enter it just in case)

to allow LP 5.1 level 22 and M level 23 edit script (bin/goptimize.sh) on line 291, change

b)
opt_b="$OPTARG"
if [[ ! "$opt_b" =~ ^[1-9]$ && ! "$opt_b" =~ ^1[0-9]$ && ! "$opt_b" =~ ^2[0-[COLOR="Red"]1[/COLOR]]$ || ! "$opt_d" ]]; then
usage; exit 1;
fi

to

b)
opt_b="$OPTARG"
if [[ ! "$opt_b" =~ ^[1-9]$ && ! "$opt_b" =~ ^1[0-9]$ && ! "$opt_b" =~ ^2[0-[COLOR="Lime"]3[/COLOR]]$ || ! "$opt_d" ]]; then
usage; exit 1;
fi

download latest baksmali/smali & apktool2 and replace smali2.jar, baksmali2.jar & apktool.jar

p.s. always use latest apktool or you will have html errors in apps if you are repackaging resources

https://ibotpeaches.github.io/Apktool/

https://bitbucket.org/JesusFreke/smali/downloads
[Android Software Development] kpirnie:
Awesome. thanks mate

---------- Post added at 01:00 PM ---------- Previous post was at 12:53 PM ----------

Sorry bro, did all this, unfortunately same issue.

added the -b22 instead of just -b this time, updated aptool, and smail2/baksmali2 as well...
[Android Software Development] gu5t3r:
-b should be specified after -d

-d6 -b22
[Android Software Development] kpirnie:
Awesome!

There we go :)

So... opinion? Think I'm over optimizing?
[Android Software Development] gu5t3r:
Tested with latest Google Play Store v6.3.16.B ( 14.7MB --> 6.41MB )

goptimize -p -9 -zo -q0 -j0 -e- -Ei -d6 -b22 GPS.apk
[Android Software Development] sewer56lol:
I've been a fan of this tool for a long time, in fact I have been keeping my own, saves a lot of time having to use multiple separate batch scripts, I've been maintaining binary up to date version of this privately as I thought it was abandoned.

Would you be able to add support for ARM64 in the official tool? I've added it to the scripts personally for my own purposes, but it is certainly something that is a bit missing from the official version, thanks!

The architecture name in question is: arm64-v8a