Search code examples
javaandroidgradledex

Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code


I have a very strange error. I use android studio 2.3.

First of all please watch my gradle file.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.2"
    defaultConfig {
        applicationId "com.example.name.webrtcwork"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
    sourceSets.main {
        jniLibs.srcDir 'libs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.myhexaville:smart-image-picker:1.0.4'
    compile 'pub.devrel:easypermissions:1.1.3'
    compile('io.socket:socket.io-client:1.0.0') {
        exclude group: 'org.json', module: 'json'
    }
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    compile files('libs/autobanh.jar')
    compile files('libs/base_java.jar')
    compile files('libs/libjingle_peerconnection.jar')

    testCompile 'junit:junit:4.12'
}

Project clean and rebuild works successfully, but if I want to run the app, I'm getting error like this.

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.

Error:1 error; aborting

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/Users/Hayk.Mkrtchyan/.android/build-cache/7fd66238e8a360302161a82746a2b9f0a8b83132/output/jars/classes.jar' to '/Users/Hayk.Mkrtchyan/Desktop/WebRTCWork/app/build/intermediates/pre-dexed/debug/classes_547e5465c50bca12a58d5755bafa9d6a10538b52.jar'

Ok I tried many ways to solve the issues like adding targetCompatibility = '1.7' sourceCompatibility = '1.7' in my build file. This not works.

I don't want to add version 1.8 and I don't want to upgrade my android studio version to 3.0. How can I solve this?

And If I'll add the version 1.8 and will enable the jack, it gives error too like.

Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'. Cannot load Jill from build tools.

How can I fix this?


Solution

  • Thanks everyone for answer. The problem was that this library (compile 'com.myhexaville:smart-image-picker:1.0.4') gave conflict. When I removed it everything worked finally.