0

I have two Android apps I'm looking at - one that I created a while back and another that I'm just making now. When I try to compile the new one, I get an error "Error:Execution failed for task ':app:compileDebugJavaWithJavac'. compileSdkVersion 'android-25' requires JDK 1.8 or later to compile." I do not get this error with the old app. Why the difference?

New app's gradle file: apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.jtriemstra.forceconnectfromphone"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.0.0'
}

Old app's gradle file: apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.jtriemstra.timeswitch"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'commons-codec:commons-codec:1.10'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile files('libs/nmdp_speech_kit.jar')
}

In both cases, if I go to File > Project Structure, I see it pointed to the same JDK 1.7 path.

The biggest difference I can see is that the new app is using a newer version of Gradle and the Gradle wrapper...which I changed in an effort to solve another problem (see Why "This app has been built with an incorrect configuration" error occured in some phones?) But I would have expected a compile failure to be more at the javac level, not the build manager level.

Community
  • 1
  • 1
joelt
  • 2,672
  • 2
  • 24
  • 32

1 Answers1

0

It looks like the reason is, in fact, the gradle wrapper. If I take a different approach to solving my initial problem, and roll back my changes to the wrapper to use v2.8, the project compiles.

joelt
  • 2,672
  • 2
  • 24
  • 32