0

I have a small Android application that is failing to compile from command line. I can build and deploy the application to the emulator in Android Studio without issues, however when I try to build from the command line I get the error below.

gradle clean assembleDebug 

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformClassesWithDexForRelease'.

    com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I understand it's saying I've exceeded the Android 64k method limit described here:

https://developer.android.com/studio/build/multidex.html

However why would the application compile fine in Android Studio? Any idea what I'm doing wrong when compiling from the command line? Thanks in advance.

1 Answer 1

1

As it turned out I was including all the Google Play Service libraries in my dependencies, i.e. in build.gradle:

compile 'com.google.android.gms:play-services:9.4.0' 

I removed that dependency and added each Play Service library separately, i.e.:

 compile 'com.google.android.gms:play-services-maps:9.4.0' 

per their documentation:

https://developers.google.com/android/guides/setup

That way I'm only including the libraries I use. Now the app compiles both in Android Studio and on the command line. I assume Android Studio replaces the entire Play Services library with what the application needs at compile time which is why I could previously compile in Android Studio but not on the command line, but I could not confirm this. Hope this helps someone else.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.