title: Unable to execute dex: method ID not in [0, 0xffff]: 65536
body: <p>I have seen various versions of the dex erros before, but this one is new. clean/restart etc won't help. Library projects seems intact and dependency seems to be linked correctly. </p>
  
  <pre><code>Unable to execute dex: method ID not in [0, 0xffff]: 65536
  Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
  </code></pre>
  
  <p><strong><em>or</em></strong> </p>
  
  <pre><code>Cannot merge new index 65950 into a non-jumbo instruction
  </code></pre>
  
  <p><strong><em>or</em></strong> </p>
  
  <pre><code>java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
  </code></pre>
  
  <p><strong>tl;dr</strong>: Official solution from Google is finally here!</p>
  
  <p><a href="http://developer.android.com/tools/building/multidex.html" rel="noreferrer">http://developer.android.com/tools/building/multidex.html</a> </p>
  
  <p>Only one small tip, you will likely need to do this to prevent out of memory when doing dex-ing. </p>
  
  <pre><code>dexOptions {
          javaMaxHeapSize "4g"
  }
  </code></pre>
  
  <p>There's also a jumbo mode that can fix this in a less reliable way: </p>
  
  <pre><code>dexOptions {
          jumboMode true
  }
  </code></pre>
  
  <p>Update: If your app is fat and you have too many methods inside your main app, you may need to re-org your app as per</p>
  
  <p><a href="http://blog.osom.info/2014/12/too-many-methods-in-main-dex.html" rel="noreferrer">http://blog.osom.info/2014/12/too-many-methods-in-main-dex.html</a></p>