2

I get the following error whenever I am trying to compile-

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.

My build.gradle file is as follows-

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
    applicationId "com.example.sbcappium"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/notice'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license'
    exclude 'META-INF/license.txt'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
 compile fileTree(include: ['*.jar'], dir: 'libs')
apply plugin: 'android'
targetCompatibility = '1.7'
sourceCompatibility = '1.7'

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.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile group: 'net.time4j', name: 'time4j-android', version: '3.24-2016i'
testCompile 'junit:junit:4.12'
compile files('libs/cglib-nodep-3.2.4.jar')


compile files('libs/commons-exec-1.3.jar')
compile files('libs/commons-io-2.5.jar')
compile files('libs/commons-lang3-3.5.jar')
compile files('libs/commons-logging-1.2.jar')

compile files('libs/gson-2.8.0.jar')
compile files('libs/guava-21.0.jar')
compile files('libs/hamcrest-core-1.3.jar')


compile files('libs/htmlunit-driver-2.26.jar')

compile files('libs/httpcore-4.4.6.jar')
compile files('libs/httpmime-4.5.3.jar')
compile files('libs/java-client-5.0.0-BETA8.jar')

compile files('libs/jetty-io-9.4.1.v20170120.jar')
compile files('libs/jetty-util-9.4.1.v20170120.jar')
compile files('libs/jna-4.1.0.jar')

compile files('libs/junit-4.12.jar')

compile files('libs/phantomjsdriver-1.4.0.jar')
compile files('libs/sac-1.3.jar')
compile files('libs/selenium-server-standalone-3.4.0.jar')
compile files('libs/serializer-2.7.2.jar')
compile files('libs/websocket-api-9.4.3.v20170317.jar')
compile files('libs/websocket-client-9.4.3.v20170317.jar')
compile files('libs/websocket-common-9.4.3.v20170317.jar')
compile 'com.android.support:support-annotations:25.3.1'}

I have tried all the solutions provide in the following links, but nothing worked for me-

  1. Android: Dex cannot parse version 52 byte code
  2. Andrioid Studio - Error converting bytecode to dex, Cause: Dex cannot parse version 52 byte code

What is wrong with my build.gradle file? Please keep in mind that I have made every possible alteration to the gradle file according to the solutions provided in the above two links.

TFK
  • 121
  • 4
  • 14
  • Change compatibility to `1.8` You have a dependency that required 1.8, but you are trying to compile with 1.7 – Matt Clark Jun 02 '17 at 20:44
  • @MattClark - I have tried that earlier, did not work. – TFK Jun 02 '17 at 20:48
  • In what way did not work? What happened? Please quote any error message verbatim. – Ole V.V. Jun 03 '17 at 05:03
  • 1
    @OleV.V. I have provided the error above as it appears. Whenever I go to run the main java file I get the above error. – TFK Jun 05 '17 at 14:18
  • Hm, maybe this is about the `java-client-5.0.0-BETA8`, see also the compilation settings at its [build.gradle-file](https://github.com/appium/java-client/blob/master/build.gradle) It seems to have been compiled with Java-8. – Meno Hochschild Jun 06 '17 at 10:35

1 Answers1

0

please add this code to your build.gradle

  compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

I hope your problem be solved