Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
Chainfire
Old
(Last edited by Chainfire; 28th November 2012 at 10:49 AM.)
#1  
Chainfire's Avatar
Senior Moderator / Elite Recognized Developer - OP
Thanks Meter 31425
Posts: 7,981
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, 1947 views)
I AM ON VACATION
I know, I still had lots of PMs and emails to answer, problems to debug, features to implement, updates to release, people to help, etc, but it'll just have to wait. But do not despair, I will return soon to procrastinate some more.

BLOG - G+(Chainfire) - G+(Personal) - TWITTER - IRC - DONATE

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

SuperSU, Mobile ODIN, TriangleAway, DSLR Controller, CF-Root, 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 108 Users Say Thank You to Chainfire For This Useful Post: [ Click to Expand ]
 
Quinny899
Old
#2  
Quinny899's Avatar
Recognized Contributor
Thanks Meter 2782
Posts: 5,303
Join Date: Jan 2011
Location: Bolton le Sands, Near Lancaster, UK Likes: Android, Linux Hates: Windoze, Apple

 
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:
Samsung Galaxy Nexus
Archos 80 G9
LG GT540
Acer D255
 
rohan32
Old
#3  
rohan32's Avatar
Recognized Developer
Thanks Meter 3984
Posts: 1,859
Join Date: Nov 2011
Location: New Jersey

 
DONATE TO ME
Awesome work Chainfire, will play around with this in a few
Did I help you out? Consider hitting the "Thanks" button at the bottom left of my post!
Follow @rohanXmon Twitter for my latest development updates!
Like my work? Think about a donation!

AT&T HTC One XL
[KERNEL] rohan.kernel
[ROM] King Kang Developer
[ROM] AOKP Jellybean / AOKP ICS Official Maintainer
[ROM] ParanoidAndroid Jellybean Official Maintainer
[ROM] Evervolv ICS Official Maintainer
Join us in #cyanogenmod-evita on Freenode for support and discussions!


HP TouchPad
[KERNEL] XENON Kernel
[ROM] AOKP ICS Nightly Builds
[MODPACK] SUPREME Mods


Asus Nexus 7 / HTC G2
 
wildstang83
Old
(Last edited by wildstang83; 26th September 2012 at 11:51 PM.)
#4  
wildstang83's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 2756
Posts: 3,691
Join Date: Oct 2010

 
DONATE TO ME
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




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




Neo - "They weren’t dumped in the garden, they were placed in a Paradise!"
 
iBotPeaches
Old
#5  
iBotPeaches's Avatar
Senior Member
Thanks Meter 1712
Posts: 595
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 / Elite Recognized Developer - OP
Thanks Meter 31425
Posts: 7,981
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.
I AM ON VACATION
I know, I still had lots of PMs and emails to answer, problems to debug, features to implement, updates to release, people to help, etc, but it'll just have to wait. But do not despair, I will return soon to procrastinate some more.

BLOG - G+(Chainfire) - G+(Personal) - TWITTER - IRC - DONATE

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

SuperSU, Mobile ODIN, TriangleAway, DSLR Controller, CF-Root, 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
Thanks Meter 2756
Posts: 3,691
Join Date: Oct 2010

 
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.
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




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




Neo - "They weren’t dumped in the garden, they were placed in a Paradise!"
 
wanam
Old
#8  
wanam's Avatar
Recognized Developer
Thanks Meter 13688
Posts: 3,487
Join Date: Jan 2011
Location: Temara
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 .
WanamLite Roms :
Adam Kernel :
App : Language Enabler
Blog : WanamLite.com
Follow : GooglePlus, FaceBook - Twitter

 
wildstang83
Old
#9  
wildstang83's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 2756
Posts: 3,691
Join Date: Oct 2010

 
DONATE TO ME
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.




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




Neo - "They weren’t dumped in the garden, they were placed in a Paradise!"
 
Siberian Tiger
Old
#10  
Siberian Tiger's Avatar
Forum Moderator
Thanks Meter 4500
Posts: 3,611
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 ]
 
Post Reply+
Tags
apktool, faapt
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...