title: Android Studio UNEXPECTED TOP-LEVEL EXCEPTION:
body: <p>Today I am faced with a massive error that doesn't let me run a sample project on my phone.</p>
  
  <p>When Android Studio is building the project, it first shows the following targets as <code>UP-TO-DATE</code>:</p>
  
  <pre><code>....
  :demoproject:processDebugResources UP-TO-DATE
  :demoproject:generateDebugSources UP-TO-DATE
  :demoproject:compileDebugJava UP-TO-DATE
  :demoproject:proguardDebug UP-TO-DATE
  ....
  </code></pre>
  
  <p>There are dozens of these <code>UP-TO-DATE</code> log statements during the build process. However, they always halt at <code>:demoproject:dexDebug</code>. For <code>dexDebug</code>, I never seem to get an <code>UP-TO-DATE</code> log statement.</p>
  
  <p>Instead, <code>dexDebug</code> is followed by this error:</p>
  
  <pre><code>:demoproject:dexDebug
  warning: Ignoring InnerClasses attribute for an anonymous inner class
  (com.xyz.corp.sample.project.demo.a) that doesn't come with an
  associated EnclosingMethod attribute. This class was probably produced by a
  compiler that did not target the modern .class file format. The recommended
  solution is to recompile the class from source, using an up-to-date compiler
  and without specifying any "-target" type options. The consequence of ignoring
  this warning is that reflective operations on this class will incorrectly
  indicate that it is *not* an inner class.
  </code></pre>
  
  <p>Now there are dozens of these <code>Ignoring InnerClasses attribute</code> errors. They even occur for classes in the v4 support library, which is truly perplexing.</p>
  
  <p>Finally, these errors end with a new statement:</p>
  
  <pre><code>UNEXPECTED TOP-LEVEL EXCEPTION:
  at com.android.dx.command.dexer.Main.access$300(Main.java:83)
  at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
  at com.android.dx.command.dexer.Main.main(Main.java:215)
  at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
  at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
  at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
  at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
  at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
  at com.android.dx.command.dexer.Main.run(Main.java:246)
  at com.android.dx.command.dexer.Main.processOne(Main.java:632)
  at com.android.dx.command.Main.main(Main.java:106)
  ...while parsing com/xyz/corp/sdk/AbcSDKConfig.class
  1 error; aborting
  Error:Execution failed for task ':demoproject:dexDebug'.
  &gt; com.android.ide.common.process.ProcessException:    org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1
  com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
  at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
  ...while parsing com/xyz/corp/sdk/AbcSDKConfig.class
  1 error; aborting
  at com.android.dx.command.dexer.Main.processClass(Main.java:704)
  at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
  </code></pre>
  
  <p>I have already consulted the following links:</p>
  
  <p><strong>1.</strong> <a href="https://stackoverflow.com/q/29965398"><strong>Gradle finished with non-zero exit value 1</strong></a>.</p>
  
  <p><strong>2.</strong> <a href="https://stackoverflow.com/q/3308010/3287204"><strong>What is the “Ignoring InnerClasses attribute” warning output during compilation?</strong></a>.</p>
  
  <p>I'm not sure they apply to my situation. I'm not even able to <em>run</em> the project. I've updated my IDE to SDK Tools 22.0.1 and modified the <code>buildToolsVersion</code> tag in my <code>build.gradle</code> file, but to no avail. Can someone please guide me how to deal with this error ? All help will be appreciated.</p>
  
  <p>Oh, and here is my <code>build.gradle</code>:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 22
      buildToolsVersion '22.0.1'
  
      packagingOptions {
          exclude 'META-INF/LICENSE'
          exclude 'META-INF/NOTICE'
      }
  
      defaultConfig {
          applicationId "com.xyz.corp.demo.project"
          minSdkVersion 10
          targetSdkVersion 22
  
          versionCode 2060200
          versionName '2.6.02.00'
      }
  
      buildTypes {
          debug {
  
              minifyEnabled true
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
  
          release {
              minifyEnabled true
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  
              applicationVariants.all { variant -&gt;
                  variant.outputs.each { output -&gt;
                      def file = output.outputFile
                      output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
                  }
              }
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile 'com.android.support:appcompat-v7:22.1.0'
  
      compile project(':xyzSDK')
  }
  </code></pre>
  
  <p>Please <strong>HELP !!!</strong></p>