0

I imported a code from github and tried to run it on my device, and encountered this error:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 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

When I googled it, I found out that it has something to do with the number of methods where the code is getting too big, but it's not the fact that it only contains one Java class with a couple of methods. What else could be the problem?

Any suggestions will be appreciated.

Nayantara Jeyaraj
  • 2,624
  • 7
  • 34
  • 63
Toka A. Amin
  • 156
  • 1
  • 2
  • 16
  • Did you try `rebuild project` and `clear cache and restart` – Jyoti JK Mar 20 '18 at 05:10
  • 2
    https://developer.android.com/studio/build/multidex.html Please go through this link, It doesn't need all methods to be in your project. You may have many dependencies in your project. Remove unwanted dependencies. – livemaker Mar 20 '18 at 05:13
  • Check this question https://stackoverflow.com/questions/47015038/cause-com-android-dex-dexexception-multiple-dex-files-define-lorg-apache-commo – Ninja Mar 20 '18 at 05:28

2 Answers2

0

Many times it's not your method references that exceeds the 64k limit.It's the method references in the libraries you use such ad Http legacy library , it has a huge number of methods .. I've found that if I include Http legacy to any project than i've to enable multidex. read this for more info
https://developer.android.com/studio/build/multidex.html

himel
  • 500
  • 5
  • 14
0

Add "multiDexEnabled true" in your build.gradle file under the defaultConfig.