0

I went through all the questions on stack and other sites for following error, but I am still not able to resolve it. I also did Invalidate Cache and restarted Android Studio I am using JDK 1.8, my Java_HOME path is set to 1.8 and embedded JDK checkbox is checked. I am using latest Android Studio and classpath 'com.android.tools.build:gradle:3.0.0'

Following is my gradle file

buildscript {
    ext.kotlin_version = '1.1.51'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath "org.greenrobot:greendao-gradle-plugin:3.2.2"
        classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

// Define versions in a single place
ext {
    // Sdk and tools
    minSdkVersion = 21
    targetSdkVersion = 23
    compileSdkVersion = 26

    // App dependencies
    supportLibraryVersion = '27.0.0'
    constraintLayoutVersion = "1.0.2"
    butterKnifeVersion = "8.8.1"
    greenDaoVersion = "3.2.2"
    swipeLayoutVersion = "1.2.0"
    rxjavaVersion = '2.1.7'
    rxandroidVersion = '2.0.1'
    rxjacva2ExtensionsVersion = '0.18.1'

    // Test dependencies
    junitVersion = '4.12'
    mockitoVersion = '2.11.0'
    hamcrestVersion = '1.3'
    runnerVersion = '1.0.1'
    rulesVersion = '1.0.1'
    espressoVersion = '3.0.1'
    powerMockito = '2.0.0-beta.5'
}

Any help would be greatly appreciated

  • Possible duplicate of [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi) – Jens Jan 03 '18 at 11:28
  • @Jens I know but none of the answers worked for me. i l already said i went through all the questions relating to it –  Jan 03 '18 at 11:29

1 Answers1

0

It might be due to

supportLibraryVersion = '27.0.0'

Reduce to 26 and check.

Support library should match with the compileSdkVersion.

TargetSDK and compileSDK Version also should match.

There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

Sometime It might be due to the thirdaprty library which added in the gradle doesn't support java 1.8 You need to cross check the libraries and supported JDK version.

lib4backer
  • 3,337
  • 3
  • 18
  • 16
  • Please maintain targetsdk and compile sdk same , in your case 26. – lib4backer Jan 03 '18 at 11:51
  • I am getting clean project error when i change it to 26 Error:Execution failed for task ':app:preMockDebugBuild'. > Failed to create parent directory 'E:\Work\Android\Lea\app\build' when creating directory 'E:\Work\Android\Lea\app\build\intermediates\prebuild\mock\debug' –  Jan 03 '18 at 12:04
  • Did u cross-checked the libraries which u added which support JDK 1.8? Or else try to use the very latest version third party libraries. – lib4backer Jan 03 '18 at 12:05
  • I am using all latest version of third-party libraries, how do i cross-check the libraries support 1.8? –  Jan 03 '18 at 12:07
  • Which is the swipelayout library? – lib4backer Jan 03 '18 at 12:18
  • com.daimajia.swipelayout:library –  Jan 03 '18 at 12:34