Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,737,490 Members 44,401 Now Online
XDA Developers Android and Mobile Development Forum

[DevTOOL][2012-10-01] Fast AAPT (#2) - Speed up Eclipse/apktool/etc

Tip us?
 
Chainfire
Old
(Last edited by Chainfire; 28th November 2012 at 10:49 AM.)
#1  
Chainfire's Avatar
Senior Moderator / Senior Recognized Developer - Where is my shirt? - OP
Thanks Meter 48819
Posts: 8,983
Join Date: Oct 2007

 
DONATE TO ME
Default [DevTOOL][2012-10-01] Fast AAPT (#2) - Speed up Eclipse/apktool/etc

Presenting: Fast AAPT - aka FAAPT

Lately Android development has been getting me down. Slow builds all over the place in many of my app projects, and my PC is blazing fast - it shouldn't all be that slow, even if you're running Eclipse!

Working on DSLR Controller has been driving me mad - testing a minor change in the underlying communications library, then building and launching the app - ugh! So I set out to fix this. I had done all the usual tricks, even gave Eclipse loads more memory (helped with regular performance, but not building) but nothing major seemed to change. Then I figured out most of the time building was spent in AAPT. So I synced my AOSP repo (2012.09.26, took a few minutes), tried to get the Windows SDK to build on my Linux box (took several hours) and finally got to actually mucking with the source.

Found the bottleneck (for my long-build-time projects at least, related to XML file compilation) and fixed it (by introducing a simple cache). "DLSR Controller" build time has gone down from 35 seconds minimum, to 2-3 seconds ( >10 times faster). Hell, I can even turn "Build Automatically" back on without getting constant delays!

Note that my build times quoted only apply to incremental internal builds. If your images still need to be "crushed" (optimized), or you're "exporting" an APK (final build for publication), build time will still be significantly longer. However, during normal development and testing (by far most builds if you're making an app in Eclipse) those stages are not performed, and builds should be lightning fast.

"Fixed" is a big word though, right now it's more of a "hack", and it needs some pollish, so the patch can be submitted to AOSP. I don't want to keep it from you for that long, so my first test build is attached - don't use it in production builds..

Patch code has been submitted to:
AOSP - #1 Cancelled, #2 Review in Progress ... superseded by ctate rewrite
AOKP - #1 Merged, #2 Merged
CM - #1 Cancelled, #2 Merged

Attached ZIP includes Linux, Windows and Mac OS X versions.

The files are drop-in replacement, but I would certainly advise you to backup the originals for your production builds! Also, don't forget to chmod/chown on Linux or it won't work.

Enjoy and leave some feedback

Will this help your project build ?

A quick way to spot if this will have effect on your slow build is as follows:

- In Eclipse, set Build output to Verbose under Window -> Preferences -> Android -> Build.
- Clean and build your project.
- If the build pauses on lines in the "(new resource id <filename> from <filename>)" format, you have the problem FAAPT fixes

(of course, you can also run aapt manually if you know how, you'll get the same output)

In a full framework build the optimizations only affect a very small portion of the actions done during the build, so you won't see any spectaculair speed increases there.

Update (#2)

I have updated the patch code to fix problems with Mac OS X compatibility, I've also included a Mac OS X binary in the new zip file.

-----

( v1: 557 )
Attached Files
File Type: zip faapt-2.zip - [Click for QR Code] (1.08 MB, 2680 views)
BLOG - G+(Chainfire) - G+(Personal) - TWITTER - IRC - DONATE

A proper quote includes only the relevant paragraphs, and a proper post never ends with the word "why"

Android
HTC G1, Hero, One
Samsung i5800, i9000*2, P1000*2, P7100, i9100*2, N7000, P6800, i9300, N7100, i9505, N9005
Sony T LT30p, Z C6603
Nexus Galaxy*2, N7, N10, N7-2013

SuperSU, Mobile ODIN, TriangleAway, DSLR Controller, CF-Root, 500 Firepaper, OpenDelta, USB Host Diagnostics, ExynosAbuseAPK, Live dmesg+logcat, NoMoarPowah!, CF-Bench, Chainfire3D, CF.lumen, SGS2 SIM Unlocker, GingerBreakAPK, SuperPower, and more!

Windows Mobile 5/6
E-Mobile EM-ONE
HTC Wizard*2, Kaiser, Touch, Diamond, Pro, HD*2, Diamond 2, Pro 2*2, HD2*2
Samsung i780, i900*2, i8000*2, b7300, b7320, b7330, b7620*2, b6520

WMWifiRouter, KaiserTweak, FPUEnabler, WMLongLife, WMRegOptimizer, CFC+GUI, TF3D+v2 ports, Kaiser+Omnia2+Snapdragon 3D drivers, GfxBoost, and more!

Windows Phone 7
LG GW910

NOTICE: I do not respond to tech support questions through PM.
The Following 111 Users Say Thank You to Chainfire For This Useful Post: [ Click to Expand ]
 
Quinny899
Old
#2  
Quinny899's Avatar
Recognized Contributor
Thanks Meter 3830
Posts: 6,222
Join Date: Jan 2011
Location: Bolton le Sands, Near Lancaster, UK

 
DONATE TO ME
So that's what's been killing the speed of my eclipse then. It froze so often I had to switch to AIDE on my phone. Hopefully this'll speed it up a little

Sent from my Galaxy Nexus using Tapatalk 2

 
Devices:
Nexus 5
Galaxy Nexus
Nexus 7 FHD
Archos 80 G9
LG GT540
 
rohan32
Old
#3  
rohan32's Avatar
Retired Forum Moderator / Recognized Developer
Thanks Meter 5036
Posts: 1,986
Join Date: Nov 2011
Location: New Jersey

 
DONATE TO ME
Awesome work Chainfire, will play around with this in a few
#teamkang

Follow me on Twitter
@rohanXm
for the my latest development updates

Devices:
LG Nexus 4 (DD)
Asus Nexus 7 (DD)
HTC One XL
LG Optimus G
HTC G2
 
wildstang83
Old
(Last edited by wildstang83; 26th September 2012 at 11:51 PM.)
#4  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter 3874
Posts: 4,748
Join Date: Oct 2010
Location: Behind You ;) XDA Mod Team 6
Thanks brother, gonna give it a try right now on Linux

EDIT:

It works. Gave it three tries. Went consistently around 19.1 sec with FAAPT and 33.9 sec with regular AAPT. This is on the Linux version. Good job




H.I.T - HTC International Team


Forum Rules | New Users Guide | XDA Tour | Report Posts | Need a Moderator?

 
iBotPeaches
Old
#5  
iBotPeaches's Avatar
Senior Member
Thanks Meter 2074
Posts: 699
Join Date: Apr 2011
Location: KCK

 
DONATE TO ME
Amazing work. Handles large resources like framework-res a lot faster.
 
Chainfire
Old
#6  
Chainfire's Avatar
Senior Moderator / Senior Recognized Developer - Where is my shirt? - OP
Thanks Meter 48819
Posts: 8,983
Join Date: Oct 2007

 
DONATE TO ME
Quote:
Originally Posted by wildstang83 View Post
Thanks brother, gonna give it a try right now on Linux

EDIT:

It works. Gave it three tries. Went consistently around 19.1 sec with FAAPT and 33.9 sec with regular AAPT. This is on the Linux version. Good job
Glad to hear the Linux version also works! Too bad your increase is not as much as mine, but I guess it depends heavily on the amount and type of assets in your project.
BLOG - G+(Chainfire) - G+(Personal) - TWITTER - IRC - DONATE

A proper quote includes only the relevant paragraphs, and a proper post never ends with the word "why"

Android
HTC G1, Hero, One
Samsung i5800, i9000*2, P1000*2, P7100, i9100*2, N7000, P6800, i9300, N7100, i9505, N9005
Sony T LT30p, Z C6603
Nexus Galaxy*2, N7, N10, N7-2013

SuperSU, Mobile ODIN, TriangleAway, DSLR Controller, CF-Root, 500 Firepaper, OpenDelta, USB Host Diagnostics, ExynosAbuseAPK, Live dmesg+logcat, NoMoarPowah!, CF-Bench, Chainfire3D, CF.lumen, SGS2 SIM Unlocker, GingerBreakAPK, SuperPower, and more!

Windows Mobile 5/6
E-Mobile EM-ONE
HTC Wizard*2, Kaiser, Touch, Diamond, Pro, HD*2, Diamond 2, Pro 2*2, HD2*2
Samsung i780, i900*2, i8000*2, b7300, b7320, b7330, b7620*2, b6520

WMWifiRouter, KaiserTweak, FPUEnabler, WMLongLife, WMRegOptimizer, CFC+GUI, TF3D+v2 ports, Kaiser+Omnia2+Snapdragon 3D drivers, GfxBoost, and more!

Windows Phone 7
LG GW910

NOTICE: I do not respond to tech support questions through PM.
The Following 2 Users Say Thank You to Chainfire For This Useful Post: [ Click to Expand ]
 
wildstang83
Old
#7  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter 3874
Posts: 4,748
Join Date: Oct 2010
Location: Behind You ;) XDA Mod Team 6
Quote:
Originally Posted by Chainfire View Post
Glad to hear the Linux version also works! Too bad your increase is not as much as mine, but I guess it depends heavily on the amount and type of assets in your project.
I tested on a theme project of mine, so its heavy in img files. Thats probably why. I'm not complaining one bit. Absolutely love it and can't wait to try it out on my other apps




H.I.T - HTC International Team


Forum Rules | New Users Guide | XDA Tour | Report Posts | Need a Moderator?

 
wanam
Old
#8  
wanam's Avatar
Recognized Contributor / Developer
Thanks Meter 21057
Posts: 4,570
Join Date: Jan 2011
Location: Temara

 
DONATE TO ME
Quote:
Originally Posted by Chainfire View Post
Glad to hear the Linux version also works! Too bad your increase is not as much as mine, but I guess it depends heavily on the amount and type of assets in your project.
Indeed, tested the Windows version and yes it gives a very good result with a amount of assets, i got 7 time faster than the normal one on Eclipse, too bad we can't use it for production, we need one for Apktool .
I'm out until 04/08/2014.

Apps : Wanam Xposed - XSense - Language Enabler - YouTube AdAway - Xposed Torch

Blog : WanamLite.com
Follow : GooglePlus - Twitter
 
wildstang83
Old
#9  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter 3874
Posts: 4,748
Join Date: Oct 2010
Location: Behind You ;) XDA Mod Team 6
Quote:
Originally Posted by wanam View Post
Indeed, tested the Windows version and yes it gives a very good result with a amount of assets, i got 7 time faster than the normal one on Eclipse, too bad we can't use it for production, we need one for Apktool .
Actually, I was using it with APKTool.




H.I.T - HTC International Team


Forum Rules | New Users Guide | XDA Tour | Report Posts | Need a Moderator?

 
Siberian Tiger
Old
#10  
Siberian Tiger's Avatar
Forum Moderator
Thanks Meter 5522
Posts: 4,109
Join Date: Dec 2010
Location: Piraeus

 
DONATE TO ME
Thanks CF.
Decompiling recompiling now is so fast

The Following User Says Thank You to Siberian Tiger For This Useful Post: [ Click to Expand ]
Tags
apktool, faapt
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes