title: Using Gradle to split external libraries in separated dex files to solve Android Dalvik 64k methods limit
body: <p>Is there a <code>proper/easy</code> way to solve the 64k methods limit using Gradle?</p>
  
  <p>I mean some custom Gradle task to use pre-dexed jars to create separated dex files, instead of a single <code>classes.dex</code>.</p>
  
  <p>Thank you</p>
  
  <p>Ivan</p>
  
  <h3>Current status</h3>
  
  <p>Currently, I'm struggling with GMS: it brings in 20k methods to use Analytics. I use Proguard to strip down what's not need, but still... 72k methods and counting... </p>
  
  <p>I can split <code>classes.dex</code> in two file using <code>dx</code> parameter <strong>--multi-dex</strong>. I achieved it manually editing </p>
  
  <pre><code>sdk/build-tools/android-4.4W/dx
  </code></pre>
  
  <p>and editing last line like this:</p>
  
  <pre><code>exec java $javaOpts -jar "$jarpath" --multi-dex "$@"
  </code></pre>
  
  <p>My APK file now contains <code>__classes.dex__ and __classes2.dex__</code>.</p>
  
  <p>I'm trying to dynamically load the second file with a few methods:</p>
  
  <ul>
  <li>Dexdex <a href="https://github.com/behumble/dexdex">link</a></li>
  <li>Dexter <a href="https://gist.github.com/nickcaballero/7045993">link</a></li>
  <li>Secondary dex gradle <a href="https://github.com/creativepsyco/secondary-dex-gradle">link</a></li>
  </ul>
  
  <p>Unfortunately still no luck. I really hope some Google/Facebook/Square guru can provide a proper solution.</p>