Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP Chainfire

27th September 2012, 12:30 AM   |  #1  
Chainfire's Avatar
OP Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 55,840
 
9,489 posts
Join Date:Joined: Oct 2007
Donate to Me
More
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, 2836 views)
Last edited by Chainfire; 28th November 2012 at 11:49 AM.
The Following 111 Users Say Thank You to Chainfire For This Useful Post: [ View ]
27th September 2012, 12:33 AM   |  #2  
Quinny899's Avatar
Recognized Contributor
Flag Bolton le Sands, Near Lancaster, UK
Thanks Meter: 3,968
 
6,327 posts
Join Date:Joined: Jan 2011
Donate to Me
More
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
27th September 2012, 12:38 AM   |  #3  
rohan32's Avatar
Retired Forum Moderator / Recognized Developer
Flag New Jersey
Thanks Meter: 5,048
 
1,986 posts
Join Date:Joined: Nov 2011
Donate to Me
More
Awesome work Chainfire, will play around with this in a few
27th September 2012, 12:39 AM   |  #4  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Flag Nowheresville
Thanks Meter: 3,919
 
4,782 posts
Join Date:Joined: Oct 2010
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
Last edited by wildstang83; 27th September 2012 at 12:51 AM.
27th September 2012, 01:00 AM   |  #5  
iBotPeaches's Avatar
Senior Member
Flag KCK
Thanks Meter: 2,340
 
738 posts
Join Date:Joined: Apr 2011
Donate to Me
More
Amazing work. Handles large resources like framework-res a lot faster.
27th September 2012, 01:01 AM   |  #6  
Chainfire's Avatar
OP Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 55,840
 
9,489 posts
Join Date:Joined: Oct 2007
Donate to Me
More
Quote:
Originally Posted by wildstang83

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.
The Following 2 Users Say Thank You to Chainfire For This Useful Post: [ View ]
27th September 2012, 01:15 AM   |  #7  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Flag Nowheresville
Thanks Meter: 3,919
 
4,782 posts
Join Date:Joined: Oct 2010
Quote:
Originally Posted by Chainfire

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
27th September 2012, 01:24 AM   |  #8  
wanam's Avatar
Recognized Contributor / Developer
Flag Temara
Thanks Meter: 22,377
 
4,928 posts
Join Date:Joined: Jan 2011
Donate to Me
More
Quote:
Originally Posted by Chainfire

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 .
27th September 2012, 01:54 AM   |  #9  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Flag Nowheresville
Thanks Meter: 3,919
 
4,782 posts
Join Date:Joined: Oct 2010
Quote:
Originally Posted by wanam

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.
27th September 2012, 08:27 AM   |  #10  
Siberian Tiger's Avatar
Forum Moderator
Flag Piraeus
Thanks Meter: 5,896
 
4,283 posts
Join Date:Joined: Dec 2010
Donate to Me
More
Thanks CF.
Decompiling recompiling now is so fast

The Following User Says Thank You to Siberian Tiger For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
apktool, faapt
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes