Reducing the size of Android builds

Titanium is great – cross platform development with JavaScript but it’s really easy to make a simple mistake in iOS/Android builds that cause Android APK files to be larger than they need to be.

Typically you create a project, drop your images in the Resources/images folder and many developers only use the /Resources/android/images and /Resources/iphone/images folders to handle things like App Icons, Splash Screens etc.

If they develop iOS first, they may end up putting their app images in the Resources/images folder so backgrounds, buttons, icons etc along-side their Retina counterparts. This is fine for iOS but Android will default to using the non-retina images in the /Resources/images folder (unless you’ve put platform specific images in the /Resources/android/images folder).

This means the retina images are being packaged with your app, but aren’t being used and retina images can be BIG especially if not optimised.

So, simple tip – either:-

  • keep your *all* iOS images in the /Resources/iphone/images folder (normal and retina) and your Android images in /Resources/android/images or,
  • keep your non-retina images in the /Resources/images folder, and your retina images in /Resources/iphone/images, with any Android overrides in /Resources/Android/images

This way, Android will use the non-retina by default, unless you override them with density specific files and your retina images won’t be packaged with your APK.

This one tip can save megabytes of space in Android builds!

Freelance Web/App/Mobile Developer as BouncingFish • Speaker • TCAD + TCD Certified Developer/Instructor • Titanium Titan.