I ran into a problem of slow builds and thought I'd share the
solution.

I'm porting an iPhone app to Android, and as soon as I added the
images to the project (400+ pngs), build time went from about 5
seconds to about 40 seconds. This is on a new machine, quad core i7,
8GB ram.

The resource processor (aapt) was to blame. Every time I made a change
to a layout xml file and hit save - bam, wait 40 seconds.

After running aapt in verbose mode, it was obvious what was happening
- aapt does png optimization every single time. Optimization is slow,
and aapt only used one core. So it makes sense to turn this
optimization off. Just run optipng once, no need to optimize every
build or every time I save a layout xml file.

So how do you turn png optimization off? You can't. There is no
Eclipse setting, no command line option for aapt.

Digging around the aapt source, I noticed something funny though - it
only optimizes images in the "drawable" folders that end in ".png".
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=tools/aapt/Images.cpp#l973

Solution: rename all the pngs to end in uppercase ".PNG". Then aapt
simply copies the files without optimizing. My build time is back to 5
seconds!

(Caveat: this won't work for nine-patch files - they still need to end
in lowercase ".9.png".)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to