FORUMS

Droid Turbo Lollipop OTA, 2015 Moto G Leaked – XDA TV

Android Lollipop for the Droid Turbo has been released. That and much more … more

EVLeaks Shows Off Possible BlackBerry Android Phone

It wasn’t too long ago that we received reports of BlackBerry planning to use … more

Mysterious GG1 Google Device Stops by FCC. Glass v2?

As the year progresses, we draw further away from Google’s annual I/O … more

Material and Material Dark Hit Samsung’s Theme Store

The latest version of Touchwiz, launched alongside the Galaxy S6 and S6 Edge, … more

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

9,732 posts
Thanks Meter: 61,256
 
By Chainfire, Senior Moderator / Senior Recognized Developer - Where is my shirt? on 26th September 2012, 11:30 PM
Post Reply Subscribe to Thread Email Thread
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, 3166 views)
Last edited by Chainfire; 28th November 2012 at 10:49 AM.
The Following 112 Users Say Thank You to Chainfire For This Useful Post: [ View ]
 
 
26th September 2012, 11:33 PM |#2  
Quinny899's Avatar
Recognized Contributor
Flag Bolton le Sands, Near Lancaster, UK
Thanks Meter: 4,127
 
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
26th September 2012, 11:38 PM |#3  
rohan32's Avatar
Retired Forum Moderator / Retired Recognized Developer
Flag New Jersey
Thanks Meter: 5,049
 
Donate to Me
More
Awesome work Chainfire, will play around with this in a few
26th September 2012, 11:39 PM |#4  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Flag Nowheresville
Thanks Meter: 3,951
 
More
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; 26th September 2012 at 11:51 PM.
27th September 2012, 12:00 AM |#5  
iBotPeaches's Avatar
Senior Member
Flag KCK
Thanks Meter: 2,850
 
Donate to Me
More
Amazing work. Handles large resources like framework-res a lot faster.
27th September 2012, 12:01 AM |#6  
Chainfire's Avatar
OP Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 61,256
 
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, 12:15 AM |#7  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Flag Nowheresville
Thanks Meter: 3,951
 
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.

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, 12:24 AM |#8  
wanam's Avatar
Recognized Contributor / Developer
Flag Temara
Thanks Meter: 23,700
 
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, 12:54 AM |#9  
wildstang83's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Flag Nowheresville
Thanks Meter: 3,951
 
More
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, 07:27 AM |#10  
Siberian Tiger's Avatar
Moderator Committee - The Eye of the Tiger
Flag Piraeus
Thanks Meter: 6,577
 
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