If you have built an Android app and received this error, then congratulations, you have a lot of code! This document explains how to move past this limitation and continue building your app.

Sometimes, importing libraries using gradle dependency can lead to this error. Is there google play services library in your app? If any, instead of compile com.google.android.gms:play-services:9.4.0, you can import libraries that you only want to use for example if you want to use google map, just import com.google.android.gms:play-services-maps:9.4.0 instead com.google.android.gms:play-services:9.4.0. It will help reducing the number of dex generated. You also can use proguard to eliminate unused code.

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:

You can refer to Android Guide on how to selectively compiling APIs into your executable