title: NoClassDefFoundError with Android Studio on Android 4
body: <p>I'm in the process of converting an existing app from Eclipse to Android Studio. However, when I run it on a device running 4.x (I've tested several versions on emulators), it immediately crashes with a <code>NoClassDefFoundError</code>.</p>
  
  <p>I've tried commenting out references to the classes it can't find, but there's always another. As far as can tell, the offending class is always</p>
  
  <ol>
  <li>Within my own code</li>
  <li>An inner class (<strong>Update:</strong> With more investigation, this one isn't always true)</li>
  </ol>
  
  <p>Everything works fine on a 5.0.1 emulator (I don't have a device to test on). My <code>build.gradle</code> file is fairly long, but looks like this:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'android-apt'
  
  def AAVersion = "2.7.1"
  
  android {
      compileSdkVersion 19
      buildToolsVersion "21.1.1"
  
      defaultConfig {
          applicationId "com.myapp.android"
          minSdkVersion 8
          targetSdkVersion 19
          multiDexEnabled = true
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          }
      }
  
      packagingOptions {
          *snip*
      }
  }
  
  buildscript {
      repositories {
          mavenCentral()
  
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:1.0.0'
          classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
      }
  }
  
  repositories {
      maven {
          url "https://repo.commonsware.com.s3.amazonaws.com"
      }
  }
  
  apt {
      arguments {
          androidManifestFile variant.outputs[0].processResources.manifestFile
          resourcePackageName 'com.pact.android'
      }
  }
  
  dependencies {
      *snip compile project(':...') declarations
  
      apt "com.googlecode.androidannotations:androidannotations:$AAVersion"
      compile "com.googlecode.androidannotations:androidannotations-api:$AAVersion"
  
      compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
      compile 'com.android.support:support-v4:21.0.3'
      compile 'com.google.android.gms:play-services:3.1.36'
  
      *snip many more compile declarations*
  
      compile fileTree(dir: 'libs', include: ['*.jar'])
  }
  </code></pre>
  
  <p>Some examples of classes that cause trouble:</p>
  
  <ul>
  <li>An anonymous class that implements an interface inside the facebook library (as a library project)</li>
  <li><code>Parcelable.CREATOR</code> implementations in my models</li>
  <li>An inner class that extends android.os.Library</li>
  <li>An inner class in my own code</li>
  <li>A class that implements an interface in a library from maven</li>
  </ul>
  
  <p>What's going wrong, and how do I fix it?</p>