AWS Mobile Blog

AWS Mobile SDK for Android now uses 40% less DEX Methods

The maximum limit of 65K on DEX method count imposed by Android remains to be a significant challenge for Mobile App Developers. While there are workarounds like ProGuard and MultiDex’ing, these are cumbersome and add additional overhead. We often see developers making trade-offs with regards to the functionality in their apps due to the DEX count limit.

We heard your feedback, and have reduced the method count in the AWS Mobile SDK for Android by 40%. With this SDK update, you can avoid hitting the DEX reference limit.  

We achieved this efficiency with the following changes:

  1. Replaced Jackson with Gson. Gson is a library that performs conversions between Java objects to their JSON representation. Gson offers similar functionality and performance as Jackson, but it is lightweight compared to Jackson.
  2. Using Java’s SimpleDateFormat instead of Joda. The AWS SDK for Android used Joda to convert between date Strings and Date objects. However it adds too much overhead to the SDK, so we have replaced it with SimpleDateFormat. The thread safety issue of SimpleDateFormat is resolved with ThreadLocal.
  3. Replaced the Java StAX XML parser with Anroid’s XmlPullParser. Prior to v2.1.8, the AWS SDK used StAX to parse XML encoded contents. StAX isn’t natively supported by Android. As a result, we had to bundle Jaxp-api 1.4.4 and sjsxp 1.0.2 into the SDK via JarJar. We rewrote the XML unmarshaller with the Android’s build-in XML parser – XmlPullParser and successfully removed almost 1K method references from the runtime library of the SDK.

We will continue to optimize the method count in the subsequent SDK releases. You can get the latest version of the AWS Mobile SDK for Android by:

  1. Downloading compiled SDK from the AWS Mobile SDK Page
  2. Getting the source from GitHub
  3. Including SDK using Maven

In addition to reducing DEX methods, we have made a number of bug fixes and security updates in the SDK (see release notes for details), and recommend that you use the latest version of the SDK in your app. Please note that there are no breaking changes introduced in the SDK from the previous version (2.1.8).

If you have any questions, issues, or ideas, you can provide us feedback here.