# Error compiling because "The number of method references in a .dex file cannot exceed 64K."

**URL:** https://discourse.processing.org/t/error-compiling-because-the-number-of-method-references-in-a-dex-file-cannot-exceed-64k/40126
**Category:** Processing for Android
**Created:** [December 12, 2022, 2:29am UTC](https://discourse.processing.org/t/error-compiling-because-the-number-of-method-references-in-a-dex-file-cannot-exceed-64k/40126 "2022-12-12T02:29:02Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [December 12, 2022, 4:58pm UTC](https://discourse.processing.org/t/error-compiling-because-the-number-of-method-references-in-a-dex-file-cannot-exceed-64k/40126/2 "2022-12-12T16:58:10Z")

</div>

Hi @a_random_cat,

I am not really familiar with this topic but you can take a look at the documentation link provided in the above error message:

> **[Cómo habilitar multidex para apps con una cantidad de métodos superior a 64k...](https://developer.android.com/build/multidex?hl=es-419)**
>
> Obtén información sobre cómo habilitar la configuración de una app conocida como multidex, que le permite a tu app compilar y leer varios archivos DEX.

> Android app (APK) files contain executable bytecode files in the form of [Dalvik](https://source.android.com/devices/tech/dalvik/) Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536—including Android framework methods, library methods, and methods in your own code. In the context of computer science, the term [_Kilo, K_](https://en.wikipedia.org/wiki/Kilo-), denotes 1024 (or 2^10). Because 65,536 is equal to 64 X 1024, this limit is referred to as the ‘64K reference limit’.

Also searching for previous threads on the forum that might help you solve your issue:

> [@Build errors on a previously working sketch](https://discourse.processing.org/t/build-errors-on-a-previously-working-sketch/14784/7):
>
> I may have figured something out. After exporting the project to android studio and doing the usual fixes required following that, I got this error: Cannot fit requested classes in a single dex file (# methods: 68587 \> 65536) and somewhere else in the errors this: The number of method references in a .dex file cannot exceed 64K. the solution to this normally according to [this stackoverflow](https://stackoverflow.com/questions/36785014/the-number-of-method-references-in-a-dex-file-cannot-exceed-64k-api-17) is to add multiDexEnabled true in build.gradle This worked but I want to continue working in process…

> [@Implementing ads with admob](https://discourse.processing.org/t/implementing-ads-with-admob/2935/6):
>
> Thanks for the code. The project built just fine, and it installed no problem. On it’s own, the sketch launched, and I could see the test ad. Unfortunately, after adding my game, I got this error: :app:transformDexArchiveWithDexMergerForDebugDex: The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID no…

Hope it helps! 😉

---

_[View the full topic](https://discourse.processing.org/t/error-compiling-because-the-number-of-method-references-in-a-dex-file-cannot-exceed-64k/40126)._
