view raw
Hephaestus Hephaestus - 8 months ago 3018
Android Question

Android: Dex cannot parse version 52 byte code

I just switched to Android Studio 2.1 and this error showed up when trying to compile an app the was previously working:

Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

I had already updated the main project's file to force Java 1.7 code generation:

buildscript {
repositories {
dependencies {
classpath ''
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7

I had also updated the module as follows to set the java version:

android {
compileSdkVersion 19
buildToolsVersion "23.0.2"

defaultConfig {
applicationId ""
minSdkVersion 19
targetSdkVersion 19

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7

The submodule being built with Maven. In the pom.xml file I have also tried to force 1.7 code generation.

I understand that I am using an assembly artifact, which incorporates subordinate modules, but i have not changed any of the subordinate modules and the resulting .jar file for the module ran fine last time I compiled.

<artifactId>maven-assembly-plugin</artifactId> <!-- maven-compiler-plugin -->
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->

My question:
1) Is this an Android Studio 2.1 problem? Have others seen it?
2) Assuming this is my error and since the error message gives no help in finding the bad module, are there any recommendations on finding the V52 code? I can't just omit the libraries without breaking large amount of code. Can one inspect a .jar file to find the code revision?
Thanks in advance.


just use java 1.8 and set following works for me: it seems need the latest build tools and using jack

android {
    compileSdkVersion 23
    buildToolsVersion 24rc3

    defaultConfig {
        jackOptions {
            enabled true
    dexOptions {
        incremental true

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8