We’re excited to announce that custom builds are now available on Android! Custom builds give you the power to chose which integrations get included in your application, minimizing your app’s total size, as you might have seen from our iOS library.

Android applications can famously only have 65,536 methods. It’s easy to blow past this number when you use a series of third-party libraries. To make sure your app doesn’t surpass these limits, we’ve built a way for you to get rid of unused integrations to avoid bloat.

Custom builds let you bundle as few integrations as you need, or as many as you want. Our all module is 4MB in size and uses up 26k methods. A few integrations like Google Analytics and Flurry take up the bulk of this size, so swapping out the tools you don’t use can save you a lot of space. In comparison, our core module is a paltry 1,100 methods and 143KB in size.

A minimal build would simply include our core module. This will route all events through our servers:

compile('com.segment.analytics.android:analytics-core:+') {
  transitive = true
}

If you want to take advantage of bundled integrations, leveraging custom builds is as simple as specifying the dependencies manually:

compile('com.segment.analytics.android:analytics-core:+') {
  transitive = true
}

// Add other dependencies as you want here
compile('com.segment.analytics.android:analytics-integration-mixpanel:+') {
  transitive = true
}
compile('com.segment.analytics.android:analytics-integration-flurry:+') {
  transitive = true
}

If you still need to bundle all our integrations, you could enumerate all of those as a dependency, or simply rely on our all artifact:

compile('com.segment.analytics.android:analytics:+@aar') {
  transitive = true
}

To help you evaluate the baggage each integration comes with, we’ve compiled a handy chart for you, listing all our Android integrations, along with their sizes and method counts.

Looking to the future, we’re planning to cut down the size of our core module even further and automate custom builds for you with a Gradle plugin. Head on over to our custom build documentation if you need more information on how to setup custom builds.