title: Unable to build apk: The number of method references cannot exceed 64K
body: <p>I have been trying to build the apk file for my app, however, I am getting the error: The number of method references cannot exceed 64K.</p>
  
  <p>Here are the errors,</p>
  
  <p>Error:The number of method references in a .dex file cannot exceed 64K.
  Learn how to resolve this issue at <a href="https://developer.android.com/tools/building/multidex.html" rel="noreferrer">https://developer.android.com/tools/building/multidex.html</a></p>
  
  <p>Error:Execution failed for task ':app:transformClassesWithDexForDebug'.</p>
  
  <blockquote>
    <p>com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_15\bin\java.exe'' finished with non-zero exit value 2</p>
  </blockquote>
  
  <p>This is my gradle file,</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
  compileSdkVersion 23
  buildToolsVersion "23.0.3"
  
  defaultConfig {
      applicationId "nikhilraghavendra.hopper"
      minSdkVersion 21
      targetSdkVersion 23
      versionCode 1
      versionName "1.0"
  }
  buildTypes {
      release {
          shrinkResources true
          minifyEnabled true
          useProguard true
          proguardFiles getDefaultProguardFile('proguard-android.txt'),
                  'proguard-rules.pro'
      }
  }
  packagingOptions {
      exclude 'META-INF/LICENSE'
      exclude 'META-INF/LICENSE-FIREBASE.txt'
      exclude 'META-INF/NOTICE'
  }
  }
  
  dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:23.2.1'
  compile 'com.android.support:design:23.2.1'
  compile 'com.google.android.gms:play-services-identity:8.4.0'
  compile 'com.firebase:firebase-client-android:2.3.1'
  compile 'com.android.support:cardview-v7:23.2.1'
  compile 'com.google.android.gms:play-services:8.4.0'
  }
  </code></pre>
  
  <p>I want to build the apk file and deploy it without any issues, how do I do it?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I also tried the following</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
  compileSdkVersion 23
  buildToolsVersion "23.0.3"
  
  dexOptions {
      maxProcessCount = 4 // this is the default value
  }
  
  dataBinding{
      enabled = true
  }
  
  defaultConfig {
      applicationId "nikhilraghavendra.hopper"
      minSdkVersion 21
      targetSdkVersion 23
      resConfigs "en", "fr"
      versionCode 1
      versionName "1.0"
  }
  buildTypes {
      release {
          shrinkResources true
          minifyEnabled true
          useProguard true
          proguardFiles getDefaultProguardFile('proguard-android.txt'),
                  'proguard-rules.pro'
      }
      debug {
          minifyEnabled true
          useProguard false
      }
  }
  packagingOptions {
      exclude 'META-INF/LICENSE'
      exclude 'META-INF/LICENSE-FIREBASE.txt'
      exclude 'META-INF/NOTICE'
  }
  }
  
  dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:23.2.1'
  compile 'com.android.support:design:23.2.1'
  compile 'com.google.android.gms:play-services-identity:8.4.0'
  compile 'com.firebase:firebase-client-android:2.3.1'
  compile 'com.android.support:cardview-v7:23.2.1'
  compile 'com.google.android.gms:play-services:8.4.0'
  }
  </code></pre>
  
  <p>This is producing the message:</p>
  
  <p>Error:Execution failed for task ':app:transformClassesWithNewClassShrinkerForDebug'.</p>
  
  <blockquote>
    <p>Warnings found during shrinking, please use -dontwarn or -ignorewarnings to suppress them.</p>
  </blockquote>
  
  <p>How do I deal with this and build a proper apk? Please Help.</p>